* { margin: 0; padding: 0; box-sizing: border-box; }

:root { color-scheme: dark; }

body {
    font-family: 'Segoe UI', 'Malgun Gothic', Tahoma, sans-serif;
    background: #0a0f1e;
    color: #e8edf7;
    -webkit-tap-highlight-color: transparent;
}

.app {
    max-width: 520px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0 16px 40px;
}

.app-header {
    padding: 26px 0 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.app-header .logo { font-size: 30px; }

.app-header h1 {
    font-size: 20px;
    font-weight: 800;
    color: #f0f4ff;
    white-space: nowrap;
}

.app-header .sub {
    font-size: 11px;
    color: #4a6a9a;
    white-space: nowrap;
}

.header-right {
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    gap: 6px;
}

.top-nav {
    display: flex;
    gap: 4px;
    background: #0d1426;
    border: 1px solid #1e2a4a;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 16px;
}

.top-nav .nav-item {
    flex: 1;
    text-align: center;
    padding: 10px 6px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 700;
    color: #8ba3c7;
    text-decoration: none;
    white-space: nowrap;
}

.top-nav .nav-item.active {
    background: #c0392b;
    color: #fff;
}

.card {
    background: #121a30;
    border: 1px solid #1e2a4a;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
}

.card h2 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
    color: #f0f4ff;
}

.meta { font-size: 12px; color: #6a82ab; margin-bottom: 8px; }

.field { margin-bottom: 10px; }

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #8ba3c7;
    margin-bottom: 6px;
}

/* 체크박스는 네이티브 위젯 유지 (아래 공통 input 규칙에서 제외) */
.field input[type="checkbox"] {
    -webkit-appearance: auto;
    appearance: auto;
    width: 20px;
    height: 20px;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    accent-color: #c0392b;
    flex-shrink: 0;
    cursor: pointer;
}

.field input:not([type="checkbox"]), .field select {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    min-height: 41px;
    background: #0d1426;
    border: 1px solid #24345c;
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 15px;
    font-family: inherit;
    color: #e8edf7;
    outline: none;
}

.field input:focus, .field select:focus { border-color: #c0392b; }

.field input::placeholder { color: #3d5478; }

/* 자동완성이 강제하는 흰 배경 무력화 */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #0d1426 inset;
    -webkit-text-fill-color: #e8edf7;
    caret-color: #e8edf7;
    border: 1px solid #24345c;
    transition: background-color 99999s ease-in-out 0s;
}

/* select 커스텀 화살표 (appearance:none으로 사라진 것 복원) */
.field select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238ba3c7' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* date/time 입력: 모바일 기본 스타일 무력화 후 통일 */
.field input[type="date"],
.field input[type="time"] {
    display: block;
    text-align: left;
    color: #e8edf7;
}

.field input[type="date"]::-webkit-date-and-time-value,
.field input[type="time"]::-webkit-date-and-time-value {
    text-align: left;
    line-height: normal;
}

.field input[type="date"]::-webkit-calendar-picker-indicator,
.field input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(0.6);
    cursor: pointer;
}

.btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: #c0392b;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    font-family: inherit;
}

.btn:active { background: #a93226; }

.btn-outline {
    background: transparent;
    border: 1px solid #2a3a5a;
    color: #8ba3c7;
    margin-top: 10px;
}

.btn-secondary { background: #1f3a5c; }

.btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 14px;
    border: none;
    border-radius: 8px;
    background: #1e2a4a;
    color: #cfe0f5;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
}

.btn-sm-danger { background: #5c1f1f; color: #ffb3ab; }
.btn-sm-green { background: #14532d; color: #a7e3bd; }

.alert-success {
    background: #12331f;
    border: 1px solid #1d5c36;
    color: #a7e3bd;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 13px;
    margin-bottom: 14px;
}

.alert-error {
    background: #3d1512;
    border: 1px solid #6e2a24;
    color: #ffb3ab;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 13px;
    margin-bottom: 14px;
}

.alert-warning {
    background: #3a2f14;
    border: 1px solid #6e5a24;
    color: #d9b84a;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 13px;
    margin-bottom: 14px;
}

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #121a30;
    border: 1px solid #1e2a4a;
    border-radius: 16px;
    padding: 30px 24px;
}

.auth-card .brand {
    text-align: center;
    margin-bottom: 22px;
}

.auth-card .brand .logo { font-size: 40px; }

.auth-card .brand h1 {
    font-size: 21px;
    font-weight: 800;
    color: #f0f4ff;
    margin-top: 6px;
}

.auth-card .brand p {
    font-size: 12px;
    color: #4a6a9a;
    margin-top: 3px;
}

.auth-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: #8ba3c7;
    text-decoration: none;
}

.auth-link:hover { color: #cfe0f5; }

.otp-input {
    text-align: center !important;
    font-size: 26px !important;
    letter-spacing: 10px;
    font-weight: 800;
}

.otp-timer {
    text-align: center;
    font-size: 13px;
    color: #8ba3c7;
    margin-bottom: 14px;
}

.otp-timer .time { color: #e74c3c; font-weight: 700; }

.row-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid #1a2440;
}

.row-item:first-of-type { border-top: none; }

.row-item .info { flex: 1; min-width: 0; }

.row-item .info .name { font-weight: 700; font-size: 14px; }

.row-item .info .desc { font-size: 12px; color: #6a82ab; margin-top: 6px; }

.inline-form { display: inline; }

/* 작업 상태 배지 */
.status-pill {
    display: inline-block;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 100%;
}
.status-pill[hidden] { display: none; }

.status-pending { background: #1e2a4a; color: #8ba3c7; }
.status-running { background: #14345c; color: #7db8ff; }
.status-success { background: #12331f; color: #6fdb96; }
.status-failed  { background: #3d1512; color: #ff8a80; }
.status-stopped { background: #2a2a35; color: #9aa0b5; }
.status-user_stopped { background: #2a2a35; color: #c2c6cf; }
.status-system_stopped { background: #3a2f14; color: #f2cf77; }
.status-expired { background: #3a2f14; color: #d9b84a; }
.status-paid    { background: #2a1f4a; color: #c9a8ff; }
.status-unpaid { background: #3a2f14; color: #f2cf77; }

.job-status-group { display: flex; align-items: center; gap: 6px; max-width: 48%; flex-wrap: wrap; justify-content: flex-end; }
.job-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.job-heading .status-pill { max-width: 100%; }

/* 시도 횟수 등, 실시간으로 바뀌는 숫자를 눈에 띄게 */
.count-highlight {
    font-weight: 800;
    color: #ffb84d;
    font-variant-numeric: tabular-nums;
}

/* 보안 안내 (?) 아이콘 + 모달 */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    min-width: 26px;
    border-radius: 50%;
    background: #1e2a4a;
    color: #8ba3c7;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}
.info-icon:hover { background: #24325c; color: #b7c8e8; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 16, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}
.modal-overlay[hidden] { display: none; }

.modal-box {
    background: #141a2b;
    border: 1px solid #232d47;
    border-radius: 14px;
    padding: 20px;
    max-width: 360px;
    width: 100%;
}
.modal-box h3 { margin: 0 0 10px; font-size: 15px; color: #f0f4ff; }
.modal-box p { font-size: 13px; color: #b7c2dc; line-height: 1.65; margin: 0 0 10px; }
.modal-box p:last-of-type { margin-bottom: 16px; }
.modal-box .btn { width: 100%; }

.job-link { text-decoration: none; color: inherit; display: block; }

.job-route {
    font-size: 15px;
    font-weight: 800;
    color: #f0f4ff;
}

.job-route .arrow { color: #c0392b; margin: 0 4px; }

/* 로그 박스 */
.log-box {
    background: #060a15;
    border: 1px solid #1a2440;
    border-radius: 10px;
    padding: 12px;
    height: 320px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.7;
}

.log-line { color: #8ba3c7; word-break: break-all; }
.log-line .t { color: #3d5478; margin-right: 6px; }
.log-line.success { color: #6fdb96; }
.log-line.error { color: #ff8a80; }

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 10px;
}

.btn-add {
    display: block;
    text-align: center;
    text-decoration: none;
    padding: 14px;
    border-radius: 10px;
    background: #c0392b;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 14px;
}

/* ── 열차 목록 ── */
.train-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 10px 0 12px;
    max-height: 320px;
    overflow-y: auto;
}

.train-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid #1e2b47;
    border-radius: 10px;
    background: #0d142b;
    font-size: 13px;
    cursor: pointer;
}

.train-item input[type="checkbox"] {
    -webkit-appearance: auto;
    appearance: auto;
    width: 18px;
    height: 18px;
    min-height: 0;
    flex-shrink: 0;
    accent-color: #c0392b;
    cursor: pointer;
}

.train-item:has(input[type="checkbox"]:checked) {
    border-color: #c0392b;
    background: #16101a;
}

.train-info { flex: 1; min-width: 0; }

.train-main {
    color: #e8ecf6;
    font-weight: 700;
    white-space: nowrap;
}

.train-sub {
    color: #8a97b8;
    font-size: 12px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn:disabled {
    background: #1e2a4a;
    color: #5a6f92;
    cursor: not-allowed;
}

@media (max-width: 400px) {
    .form-grid-2 { grid-template-columns: 1fr; gap: 0; }
}
