/* ── 공통 레이아웃 ── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Malgun Gothic", "맑은 고딕", -apple-system, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f5f6fa;
}

/* ── 네비게이션 (빅밸류 공식 브랜드: 딥 인디고 + 라이트 퍼플 + 민트 액센트) ── */
.navbar {
    background: linear-gradient(90deg, #4434E2 0%, #9E5DF9 100%);
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 52px;
    box-shadow: 0 2px 8px rgba(68, 52, 226, 0.25);
}

.navbar .brand {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    margin-right: 40px;
    text-decoration: none;
    letter-spacing: -0.2px;
}

.navbar a {
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    padding: 14px 16px;
    font-size: 14px;
    transition: color 0.18s, background 0.18s;
    position: relative;
}

.navbar a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.10);
}

.navbar a.active {
    color: #fff;
}
.navbar a.active::after {
    content: '';
    position: absolute;
    left: 12px; right: 12px; bottom: 0;
    height: 3px;
    background: #00E49B;
    border-radius: 2px 2px 0 0;
    box-shadow: 0 0 8px rgba(0, 228, 155, 0.5);
}

/* ── 메인 컨텐츠 ── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    color: #2c3e50;
}

/* ── 요약 카드 ── */
.summary-cards {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px 24px;
    min-width: 150px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card .label {
    font-size: 12px;
    color: #888;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card .value {
    font-size: 28px;
    font-weight: 700;
}

.card .value.total    { color: #2c3e50; }
.card .value.running  { color: #2980b9; }
.card .value.completed { color: #27ae60; }
.card .value.error    { color: #e74c3c; }
.card .value.idle     { color: #95a5a6; }

/* ── 필터 바 ── */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-bar label {
    font-size: 13px;
    color: #666;
}

.filter-bar input,
.filter-bar select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
}

.filter-bar button {
    padding: 6px 16px;
    background: #2980b9;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
}

.filter-bar button:hover {
    background: #2471a3;
}

/* ── 자동 새로고침 표시 ── */
.auto-refresh {
    font-size: 12px;
    color: #999;
    margin-left: auto;
}

/* ── 테이블 ── */
.table-wrap {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

thead th {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    padding: 10px 14px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    position: sticky;
    top: 0;
}

tbody td {
    padding: 9px 14px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}

tbody tr:hover {
    background: #f0f4ff;
}

tbody tr:nth-child(even) {
    background: #fafafa;
}

tbody tr:nth-child(even):hover {
    background: #f0f4ff;
}

/* ── 상태 뱃지 ── */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    min-width: 64px;
}

.status-running   { background: #d6eaf8; color: #2471a3; }
.status-completed { background: #d5f5e3; color: #1e8449; }
.status-error     { background: #fadbd8; color: #c0392b; }
.status-timeout   { background: #fdebd0; color: #ca6f1e; }
.status-idle      { background: #eaecee; color: #7f8c8d; }

/* ── 버튼 ── */
.btn {
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: opacity 0.2s;
}

.btn:hover {
    opacity: 0.85;
}

.btn-primary {
    background: #2980b9;
    color: #fff;
}

.btn-success {
    background: #27ae60;
    color: #fff;
}

.btn-warning {
    background: #f39c12;
    color: #fff;
}

.btn-danger {
    background: #e74c3c;
    color: #fff;
}

.btn-secondary {
    background: #95a5a6;
    color: #fff;
}

.btn-sm {
    padding: 3px 8px;
    font-size: 11px;
}

/* ── 모달 ── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 8px;
    width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── 폼 ── */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 0 2px rgba(41,128,185,0.15);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

/* ── 토스트 알림 ── */
.toast-container {
    position: fixed;
    top: 60px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 13px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toast-in 0.3s ease;
    max-width: 400px;
}

.toast.success { background: #27ae60; }
.toast.error   { background: #e74c3c; }
.toast.info    { background: #2980b9; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── 빈 상태 ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #aaa;
    font-size: 14px;
}

/* ── 로딩 ── */
.loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* ── 에러 텍스트 ── */
.error-text {
    max-width: 300px;
    white-space: normal;
    word-break: break-all;
    font-size: 12px;
    color: #c0392b;
}

/* ── 액션 버튼 그룹 ── */
.action-group {
    display: flex;
    gap: 4px;
}

/* ── 실패 행 강조 ── */
tbody tr.row-failed {
    background: #fff0f0 !important;
}

tbody tr.row-failed:hover {
    background: #ffe0e0 !important;
}

/* ── 이벤트 피드 심각도 ── */
.severity-error    { background: #fadbd8; color: #c0392b; }
.severity-warn     { background: #fdebd0; color: #ca6f1e; }
.severity-info     { background: #eaecee; color: #7f8c8d; }
.severity-critical { background: #f1948a; color: #7b241c; }

/* ── 섹션 구분 ── */
.section-title {
    font-size: 18px;
    font-weight: 700;
    margin: 32px 0 16px;
    color: #2c3e50;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 8px;
}

/* ── 비밀번호 마스크 ── */
.pw-masked {
    font-family: monospace;
    letter-spacing: 2px;
    color: #95a5a6;
}

/* ── 네비 사용자 정보 / 로그아웃 ── */
.navbar .nav-spacer { flex: 1; }
.navbar .nav-userinfo { color:rgba(255,255,255,0.85); font-size:13px; margin-right:8px; }
.navbar .role-admin { background:#00E49B; color:#1a0f4a; padding:2px 8px;
    border-radius:10px; font-size:11px; font-weight:700; margin-right:6px; }
.navbar .role-user  { background:rgba(255,255,255,0.22); color:#fff; padding:2px 8px;
    border-radius:10px; font-size:11px; font-weight:700; margin-right:6px; }

/* ═══════════════════════════════════════════
   모바일 / 앱 모드 (≤768px) — 전역 반응형
   ═══════════════════════════════════════════ */

/* 햄버거 버튼 (모바일에서만 표시) */
.nav-hamburger {
    display: none;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 8px 12px;
    margin-left: auto;
}

/* 데스크탑: 모바일 컨테이너 투명 — 자식이 .navbar 의 직접 flex item 으로 동작 */
.nav-mobile-items { display: contents; }

@media (max-width: 768px) {
    .navbar {
        padding: 0 12px;
        height: auto;
        min-height: 52px;
        flex-wrap: wrap;
        align-items: center;
    }
    .navbar .brand { font-size: 16px; margin-right: 8px; }
    .nav-hamburger { display: inline-block; }

    .nav-mobile-items {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        background: linear-gradient(180deg, #4434E2 0%, #5847e8 100%);
        margin: 8px -12px 0;
        padding: 8px 0;
        border-top: 1px solid rgba(255,255,255,.18);
    }
    body.nav-open .nav-mobile-items { display: flex; }

    .navbar a {
        padding: 12px 18px;
        font-size: 15px;
        display: block;
        width: 100%;
        box-sizing: border-box;
    }
    .navbar a.active::after { display: none; }
    .navbar a.active { background: rgba(0, 228, 155, 0.18); }

    .navbar .nav-group { display: block; width: 100%; }
    .navbar .nav-group > .nav-top {
        display: block;
        padding: 12px 18px;
        font-size: 15px;
        color: rgba(255,255,255,0.92);
        cursor: pointer;
    }
    .navbar .nav-group.open > .nav-top { background: rgba(0,0,0,0.15); }

    .navbar .nav-submenu {
        position: static;
        display: none;
        box-shadow: none;
        background: rgba(0,0,0,0.18);
        border-radius: 0;
        padding: 0;
        min-width: 0;
    }
    .navbar .nav-group:hover .nav-submenu { display: none; }
    .navbar .nav-group.open .nav-submenu { display: block; }
    .navbar .nav-submenu a {
        color: rgba(255,255,255,0.88);
        padding: 11px 28px;
        font-size: 14px;
    }
    .navbar .nav-submenu a:hover,
    .navbar .nav-submenu a.active {
        background: rgba(255,255,255,0.10);
        color: #fff;
    }

    .navbar .nav-spacer { display: none; }
    .navbar .nav-userinfo {
        display: block;
        padding: 10px 18px;
        font-size: 13px;
        border-top: 1px solid rgba(255,255,255,0.12);
    }

    /* 컨텐츠 */
    .container {
        padding: 12px;
        padding-top: max(12px, env(safe-area-inset-top));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    h1 { font-size: 18px; margin-bottom: 14px; }
    h2 { font-size: 16px; }
    h3 { font-size: 15px; }

    /* 글로벌 테이블 가로 스크롤 wrapper (테이블 직접 노출 시) */
    table { font-size: 13px; }
    table th, table td { padding: 8px 10px; }

    /* 터치 타겟 확대 */
    button, input[type=button], input[type=submit], .btn, .btn-sm {
        min-height: 36px;
    }
    input[type=text], input[type=email], input[type=password],
    input[type=number], input[type=search], input[type=date], select, textarea {
        min-height: 38px;
        font-size: 15px; /* iOS auto-zoom 방지 */
    }

    /* 모달 */
    .modal-overlay .modal { max-width: 95vw !important; margin: 8px; }
}

/* 작은 폰 ≤380px */
@media (max-width: 380px) {
    .container { padding: 8px; }
    .navbar .brand { font-size: 15px; }
}

/* PWA standalone — 시스템 상단 바 회피 */
@media (display-mode: standalone) {
    body { padding-top: env(safe-area-inset-top, 0); }
    .navbar { padding-top: env(safe-area-inset-top, 0); }
}
