:root {
    --bg-color: #f1f5f9; --card-bg: #ffffff; --text-main: #0f172a; --text-muted: #64748b; --border-color: #cbd5e1;
    --state-0-bg: #475569; --state-0-border: #334155; --state-0-text: #f8fafc;
    --state-1-bg: #ea580c; --state-1-border: #c2410c; --state-1-text: #ffffff;
    --state-2-bg: #dc2626; --state-2-border: #b91c1c; --state-2-text: #ffffff;
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background-color: var(--bg-color); color: var(--text-main); margin: 0; padding: 12px; line-height: 1.5; }
.container { max-width: 800px; margin: 0 auto; background: var(--card-bg); padding: 16px; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
header { text-align: center; margin-bottom: 15px; border-bottom: 2px solid #e2e8f0; padding-bottom: 10px; }
h1 { margin: 0; font-size: 18px; color: #1e293b; }
.config-panel { display: flex; flex-direction: column; gap: 12px; background: #f8fafc; padding: 12px; border-radius: 8px; margin-bottom: 15px; border: 1px solid #e2e8f0; }
.input-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.config-group { display: flex; align-items: center; gap: 8px; }
.config-group label { font-weight: 600; font-size: 14px; color: #475569; }
.config-group input[type="text"] { padding: 6px 10px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 16px; width: 70px; font-weight: bold; text-align: center; }
.checkbox-group { background: #e2e8f0; padding: 6px 10px; border-radius: 6px; display: flex; align-items: center; }
.checkbox-group label { cursor: pointer; display: flex; align-items: center; gap: 6px; font-weight: bold; font-size: 14px; color: #1e293b; }
.checkbox-group input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: #e11d48; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-action { color: white; border: none; padding: 8px 12px; font-size: 12px; border-radius: 6px; cursor: pointer; font-weight: bold; display: flex; align-items: center; gap: 4px; }
.btn-export { background: #10b981; } .btn-export:hover { background: #059669; }
.btn-import { background: #6366f1; } .btn-import:hover { background: #4f46e5; }
.legend { display: flex; justify-content: space-around; font-size: 12px; background: #fff; padding: 8px; border-radius: 6px; border: 1px solid #e2e8f0; }
.legend-item { display: flex; align-items: center; gap: 4px; }
.color-box { width: 14px; height: 14px; border-radius: 3px; }
.tabs-container { margin-bottom: 15px; }
.tabs { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.tab { padding: 12px 8px; background: #e2e8f0; border: none; border-radius: 8px; cursor: pointer; font-weight: bold; font-size: 13px; color: #475569; white-space: nowrap; flex: 0 0 auto; min-width: 70px; text-align: center; }
.tab.active { background: #2563eb; color: #ffffff; }
.tab .badge { display: block; background: rgba(0,0,0,0.15); border-radius: 10px; font-size: 11px; margin-top: 4px; }
.tab.active .badge { background: rgba(255,255,255,0.25); }
.train-car-map { background: #1e293b; padding: 16px 10px; border-radius: 12px; border: 4px solid #64748b; margin-bottom: 20px; position: relative; }
.car-info-title { color: #ffffff; text-align: center; margin: 0 0 15px 0; font-size: 16px; font-weight: bold; position: relative; z-index: 2; }
.vertical-layout { position: relative; display: flex; justify-content: space-between; align-items: stretch; gap: 8px; }
.grip-column { flex: 1; display: flex; flex-direction: column; position: relative; z-index: 2; }
.side-label { color: #cbd5e1; font-size: 12px; font-weight: bold; text-align: center; margin-bottom: 12px; background: #334155; padding: 8px 0; border-radius: 6px; }
.aisle-vertical { width: 40px; background: transparent; position: relative; z-index: 2; }
.watermark { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(90deg); font-size: 70px; font-weight: 900; color: rgba(255, 255, 255, 0.08); white-space: nowrap; letter-spacing: 2px; pointer-events: none; z-index: 1; user-select: none; }
.grip-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 2px dashed #475569; align-items: center; }
.grip-group:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.grip-btn { width: 100%; max-width: 80px; height: 44px; border-radius: 6px; border-width: 2px; border-style: solid; font-weight: bold; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; user-select: none; }
.grip-btn:active { transform: scale(0.95); }
.grip-btn .id-text { font-size: 14px; }
.grip-btn .status-text { font-size: 10px; margin-top: 1px; font-weight: normal; }
.grip-btn.state-0 { background: var(--state-0-bg); border-color: var(--state-0-border); color: var(--state-0-text); }
.grip-btn.state-0 .status-text { opacity: 0.5; }
.grip-btn.state-1 { background: var(--state-1-bg); border-color: var(--state-1-border); color: var(--state-1-text); }
.grip-btn.state-2 { background: var(--state-2-bg); border-color: var(--state-2-border); color: var(--state-2-text); }
.nav-buttons { display: flex; justify-content: space-between; margin-top: 25px; padding-top: 15px; border-top: 1px solid #475569; position: relative; z-index: 2; }
.nav-btn { background: #2563eb; color: white; border: none; padding: 12px 16px; border-radius: 8px; font-weight: bold; font-size: 14px; cursor: pointer; flex: 1; max-width: 48%; text-align: center; }
.nav-btn:disabled { background: #475569; color: #94a3b8; cursor: not-allowed; opacity: 0.7; }
.actions { text-align: center; margin-bottom: 20px; }
.btn-submit { background: #0f172a; color: white; border: none; padding: 14px; width: 100%; font-size: 16px; font-weight: bold; border-radius: 8px; cursor: pointer; }
.output-panel { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; }
.output-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.output-header h3 { margin: 0; font-size: 15px; }
.btn-copy { background: #64748b; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-weight: bold; }
textarea { width: 100%; height: 250px; font-family: monospace; font-size: 13px; padding: 10px; border-radius: 6px; border: 1px solid #cbd5e1; box-sizing: border-box; resize: vertical; }

/* 화면 전환 로직용 */
.view-container { display: block; min-height: 100vh; }
.hidden { display: none !important; }

/* 로그인/로비 스타일 */
#loginView { display: flex; align-items: center; justify-content: center; background: #e2e8f0; }
.login-box { background: white; padding: 40px 30px; border-radius: 12px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); width: 100%; max-width: 320px; text-align: center; }
.login-box h2 { margin: 0 0 10px 0; color: #1e293b; }
.login-box p { font-size: 13px; color: #64748b; margin-bottom: 25px; }
.login-box input { width: 100%; padding: 12px; margin-bottom: 15px; border: 1px solid #cbd5e1; border-radius: 8px; box-sizing: border-box; font-size: 15px; }
.btn-primary { width: 100%; background: #2563eb; color: white; padding: 12px; border: none; border-radius: 8px; font-size: 16px; font-weight: bold; cursor: pointer; transition: background 0.2s; }
.btn-primary:hover { background: #1d4ed8; }
.error-msg { color: #dc2626; font-size: 13px; margin-top: 10px; font-weight: bold; min-height: 15px; }
#lobbyView { padding: 20px; max-width: 800px; margin: 0 auto; }
.lobby-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; border-bottom: 2px solid #cbd5e1; padding-bottom: 15px; }
.lobby-header h2 { margin: 0; color: #0f172a; }
.btn-logout { background: #64748b; color: white; border: none; padding: 8px 16px; border-radius: 6px; font-weight: bold; cursor: pointer; }
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.service-card { background: white; padding: 25px 20px; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); border: 2px solid transparent; transition: all 0.2s; text-decoration: none; display: block; }
.service-card .icon { font-size: 40px; margin-bottom: 15px; }
.service-card h3 { margin: 0 0 10px 0; font-size: 18px; color: #1e293b; }
.service-card p { margin: 0; font-size: 13px; color: #64748b; line-height: 1.5; }
.service-card.active { cursor: pointer; border-color: #cbd5e1; }
.service-card.active:hover { transform: translateY(-5px); border-color: #2563eb; box-shadow: 0 10px 15px -3px rgba(37,99,235,0.2); }
.service-card.disabled { opacity: 0.6; cursor: not-allowed; background: #f8fafc; }
.btn-back { background: #e2e8f0; color: #475569; border: none; padding: 8px 12px; border-radius: 6px; font-weight: bold; cursor: pointer; }
.btn-back:hover { background: #cbd5e1; }

/* =========================================
   💨 에어 니플 점검 & 대시보드 전용 스타일
   ========================================= */

/* 1. 위수 버튼 2x4 그리드 */
.nipple-container { display: flex; justify-content: center; padding: 20px 0; }
.nipple-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; width: 100%; max-width: 280px; background: #cbd5e1; padding: 15px; border-radius: 8px; margin: 0 auto; }
.nipple-btn { background: white; border: 2px solid #94a3b8; border-radius: 8px; height: 70px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; }
.nipple-btn:active { transform: scale(0.95); }
.nipple-btn .n-id { font-size: 20px; font-weight: bold; color: #1e293b; }
.nipple-btn .n-tags { font-size: 11px; color: #dc2626; font-weight: bold; margin-top: 4px; }
.nipple-btn.has-issue { border-color: #dc2626; background: #fee2e2; }

/* 2. 비활성화(T1) 안내 문구 */
.disabled-car-msg { text-align: center; color: #64748b; padding: 40px 20px; font-weight: bold; font-size: 16px; background: #e2e8f0; border-radius: 8px; margin: 20px; }

/* 3. 🚨 모달(팝업창) 스타일 */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: white; padding: 20px; border-radius: 12px; width: 90%; max-width: 320px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
.modal-title { font-size: 18px; font-weight: bold; margin: 0 0 15px 0; border-bottom: 2px solid #e2e8f0; padding-bottom: 10px; }
.modal-body { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.modal-checkbox { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: bold; cursor: pointer; }
.modal-checkbox input { width: 20px; height: 20px; accent-color: #dc2626; }
.modal-input { width: 100%; padding: 10px; border: 1px solid #cbd5e1; border-radius: 6px; box-sizing: border-box; font-size: 14px; margin-top: 5px; }
.modal-footer { display: flex; gap: 10px; }
.btn-modal-save { background: #2563eb; color: white; flex: 1; padding: 12px; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; }
.btn-modal-cancel { background: #e2e8f0; color: #475569; flex: 1; padding: 12px; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; }

/* 4. 모달 숨김 처리 (가장 중요) */
.hidden { display: none !important; }

/* 5. 대시보드 리스트 & 마감 토글 버튼 */
.formation-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; padding: 20px 0; }
.formation-card { background: white; border: 2px solid #cbd5e1; border-radius: 10px; padding: 15px; text-align: center; cursor: pointer; transition: all 0.2s; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.formation-card:hover { border-color: #3b82f6; transform: translateY(-2px); }
.formation-card.is-closed { border-color: #10b981; background: #ecfdf5; }
.f-title { font-size: 22px; font-weight: 900; color: #1e293b; margin: 0; }
.f-status { font-size: 13px; font-weight: bold; padding: 5px; border-radius: 6px; }
.f-status.open { background: #f1f5f9; color: #475569; }
.f-status.closed { background: #10b981; color: white; }
.f-time { font-size: 11px; color: #64748b; min-height: 14px; }

.btn-toggle-close { padding: 10px 16px; font-size: 14px; font-weight: bold; border-radius: 8px; border: none; cursor: pointer; transition: 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.btn-toggle-close.open { background: #e2e8f0; color: #475569; }
.btn-toggle-close.closed { background: #10b981; color: white; }
.btn-toggle-close:active { transform: scale(0.95); }

/* 사진 첨부 버튼 및 미리보기 스타일 */
.btn-photo { background: #f8fafc; border: 2px dashed #94a3b8; color: #475569; width: 100%; padding: 12px; border-radius: 8px; font-weight: bold; cursor: pointer; margin-top: 10px; transition: 0.2s; }
.btn-photo:hover { background: #f1f5f9; border-color: #3b82f6; color: #3b82f6; }
.photo-preview-container { position: relative; margin-top: 10px; border-radius: 8px; border: 1px solid #cbd5e1; background: #f1f5f9; padding: 5px; }
.photo-preview-img { width: 100%; max-height: 250px; object-fit: contain; border-radius: 6px; display: block; }
.btn-remove-photo { position: absolute; top: -10px; right: -10px; background: #dc2626; color: white; border: none; border-radius: 50%; width: 30px; height: 30px; font-size: 16px; font-weight: bold; cursor: pointer; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }