/* ════════════════════════════════════════════════════
   GTX-A FRACAS 종합 분석 시스템 — 전체 스타일
   프리미엄 다크사이드바 + 모던 대시보드 디자인
   ════════════════════════════════════════════════════ */

:root {
    --sidebar-w: 220px;
    --sidebar-bg: #0d1117;
    --sidebar-border: #21262d;
    --accent: #3b82f6;
    --accent2: #8b5cf6;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
    --text-main: #1a1a2e;
    --text-sub: #6b7280;
    --border: #e5e7eb;
    --red: #ef4444;
    --orange: #f97316;
    --green: #22c55e;
    --teal: #14b8a6;
    --purple: #8b5cf6;
    --chronic-color: #ef4444;
    --repeat-color: #f59e0b;
}

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

body {
    font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
    background: var(--bg);
    display: flex;
    min-height: 100vh;
    color: var(--text-main);
}

/* ══════════════ SIDEBAR ══════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow: hidden;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 18px 18px;
    border-bottom: 1px solid var(--sidebar-border);
}

.logo-icon {
    font-size: 2em;
}

.logo-title {
    color: #f0f6fc;
    font-size: 0.95em;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.logo-sub {
    color: #8b949e;
    font-size: 0.72em;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    overflow-y: auto;
}

.nav-group-label {
    color: #484f58;
    font-size: 0.68em;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 6px 8px 8px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: #8b949e;
    font-size: 0.875em;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.18s;
    text-decoration: none;
    position: relative;
}

.nav-item:hover {
    background: #161b22;
    color: #c9d1d9;
}

.nav-item.active {
    background: var(--accent-glow);
    color: #58a6ff;
    border-left: 3px solid var(--accent);
    padding-left: 9px;
}

.nav-icon {
    font-size: 1.1em;
    width: 20px;
    text-align: center;
}

.nav-label {
    flex: 1;
}

.nav-badge {
    background: #ef4444;
    color: #fff;
    border-radius: 10px;
    font-size: 0.7em;
    font-weight: 700;
    padding: 1px 6px;
    min-width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--sidebar-border);
}

.last-update {
    color: #58a6ff;
    font-size: 0.78em;
    font-weight: 600;
}

.sidebar-footer-label {
    color: #484f58;
    font-size: 0.68em;
    margin-top: 3px;
}

/* ══════════════ MAIN CONTENT ══════════════ */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── 상단 topbar ── */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
}

.topbar-title {
    font-size: 1.05em;
    font-weight: 700;
    color: var(--text-main);
}

.topbar-kpi-row {
    display: flex;
    gap: 24px;
}

.topbar-kpi {
    text-align: center;
    line-height: 1.2;
}

.topbar-kpi-val {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--accent);
    display: block;
}

.topbar-kpi-label {
    font-size: 0.68em;
    color: var(--text-sub);
}

/* ══════════════ SECTIONS ══════════════ */
.content-section {
    padding: 24px 28px;
    display: none;
    animation: fadeUp 0.25s ease;
}

.content-section.active {
    display: block;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

/* ══════════════ KPI GRID ══════════════ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.kpi-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.kpi-card {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 18px 16px;
    box-shadow: var(--card-shadow);
    border-top: 4px solid var(--accent);
    transition: transform 0.15s, box-shadow 0.15s;
    text-align: center;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.kpi-card.kpi-blue {
    border-top-color: var(--accent);
}

.kpi-card.kpi-red {
    border-top-color: var(--red);
}

.kpi-card.kpi-orange {
    border-top-color: var(--orange);
}

.kpi-card.kpi-green {
    border-top-color: var(--green);
}

.kpi-card.kpi-purple {
    border-top-color: var(--purple);
}

.kpi-card.kpi-teal {
    border-top-color: var(--teal);
}

.kpi-icon {
    font-size: 1.4em;
    margin-bottom: 6px;
}

.kpi-val {
    font-size: 1.9em;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    margin-bottom: 4px;
}

.kpi-label {
    font-size: 0.72em;
    color: var(--text-sub);
}

/* ══════════════ CARDS ══════════════ */
.card {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 20px 22px;
    box-shadow: var(--card-shadow);
    margin-bottom: 16px;
}

.card-header {
    font-size: 0.9em;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 14px;
}

.card-hint {
    font-size: 0.75em;
    font-weight: 400;
    color: var(--text-sub);
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.card-header-row .card-header {
    margin-bottom: 0;
}

/* ══════════════ CHART GRIDS ══════════════ */
.chart-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.chart-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.chart-hint-center {
    text-align: center;
    color: var(--text-sub);
    font-size: 0.82em;
    margin: 30px 0;
}

/* ══════════════ INFO BANNER ══════════════ */
.info-banner {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 13px 18px;
    font-size: 0.85em;
    color: #1e3a5f;
    margin-bottom: 16px;
    line-height: 1.6;
}

.info-icon {
    font-size: 1.1em;
    margin-right: 6px;
}

.badge-chronic-label {
    display: inline-block;
    background: #fef2f2;
    color: var(--chronic-color);
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 1px 8px;
    font-size: 0.88em;
    font-weight: 600;
    margin-left: 8px;
}

.badge-repeat-label {
    display: inline-block;
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 1px 8px;
    font-size: 0.88em;
    font-weight: 600;
    margin-left: 4px;
}

/* ══════════════ RECURRING SUMMARY ══════════════ */
.recurring-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 16px;
}

.rec-sum-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: var(--card-shadow);
    border-left: 4px solid var(--accent);
    text-align: center;
}

.rec-sum-card.chronic {
    border-left-color: var(--chronic-color);
}

.rec-sum-val {
    font-size: 1.7em;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    margin-bottom: 4px;
}

.rec-sum-label {
    font-size: 0.72em;
    color: var(--text-sub);
}

/* ══════════════ FILTERS ══════════════ */
.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-row.flex-wrap {
    flex-wrap: wrap;
}

.search-input {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85em;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 180px;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.82em;
    background: #fff;
    cursor: pointer;
    outline: none;
}

select:focus {
    border-color: var(--accent);
}

.result-count {
    font-size: 0.78em;
    color: var(--text-sub);
    white-space: nowrap;
}

/* ══════════════ TABLES ══════════════ */
.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.825em;
}

thead th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    text-align: center;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid #f1f5f9;
    text-align: center;
    vertical-align: middle;
}

tbody tr:hover td {
    background: #f8faff;
}

.text-left {
    text-align: left;
}

/* 뱃지 */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.78em;
    font-weight: 600;
    white-space: nowrap;
}

.badge-chronic {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.badge-repeat {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.badge-normal {
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.badge-field {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
}

.badge-depot {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.badge-impact-severe {
    background: #fef2f2;
    color: #dc2626;
}

.badge-impact-minor {
    background: #fffbeb;
    color: #b45309;
}

.badge-impact-nil {
    background: #f0fdf4;
    color: #16a34a;
}

/* ══════════════ PAGINATION ══════════════ */
.table-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 14px;
    font-size: 0.85em;
}

.table-pagination button {
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.15s;
}

.table-pagination button:hover:not(:disabled) {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.table-pagination button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

#page-info {
    color: var(--text-sub);
}

/* ══════════════ 사이드바 인증 UI ══════════════ */
.auth-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
}

.auth-avatar {
    font-size: 1.4em;
}

.auth-name {
    color: #c9d1d9;
    font-size: 0.82em;
    font-weight: 600;
}

.auth-role {
    color: #8b949e;
    font-size: 0.7em;
    margin-top: 1px;
}

.auth-hint {
    color: #484f58;
    font-size: 0.68em;
    margin-top: 4px;
}

.btn-login {
    width: 100%;
    padding: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-login:hover {
    background: #2563eb;
}

.btn-logout {
    width: 100%;
    padding: 6px;
    background: transparent;
    color: #8b949e;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 0.75em;
    cursor: pointer;
    margin-top: 4px;
    transition: all 0.15s;
}

.btn-logout:hover {
    background: #161b22;
    color: #f85149;
    border-color: #f85149;
}

.nav-item-entry {
    background: rgba(59, 130, 246, 0.08);
    border: 1px dashed #3b82f6;
    color: #58a6ff !important;
}

/* ══════════════ 로그인 모달 ══════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

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

.modal-box {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1em;
    font-weight: 700;
    color: var(--text-main);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.1em;
    cursor: pointer;
    color: var(--text-sub);
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.modal-close:hover {
    background: #f1f5f9;
}

.modal-body {
    padding: 22px;
}

.modal-desc {
    font-size: 0.85em;
    color: var(--text-sub);
    margin-bottom: 16px;
}

.modal-body .form-group label {
    display: block;
    font-size: 0.82em;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}

.modal-body input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9em;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-body input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.login-error {
    color: var(--red);
    font-size: 0.8em;
    margin-top: 8px;
    min-height: 18px;
}

.btn-login-modal {
    width: 100%;
    padding: 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    margin-top: 16px;
    transition: background 0.15s, transform 0.1s;
}

.btn-login-modal:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-login-modal:active {
    transform: translateY(0);
}

/* ══════════════ 고장 입력 폼 ══════════════ */
.form-card {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 22px 24px;
    margin-bottom: 16px;
    box-shadow: var(--card-shadow);
    border-left: 4px solid var(--accent);
}

.form-card:nth-child(2) {
    border-left-color: var(--red);
}

.form-card:nth-child(3) {
    border-left-color: var(--orange);
}

.form-card:nth-child(4) {
    border-left-color: var(--teal);
}

.form-card:nth-child(5) {
    border-left-color: var(--purple);
}

.form-card-title {
    font-size: 0.92em;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px 18px;
}

.form-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.78em;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}

.req {
    color: var(--red);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875em;
    outline: none;
    background: #fff;
    transition: border-color 0.18s, box-shadow 0.18s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
    resize: vertical;
    line-height: 1.5;
}

/* 폼 액션 버튼 */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
    margin-bottom: 12px;
}

.btn-reset-form {
    padding: 10px 22px;
    background: #fff;
    color: var(--text-sub);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-reset-form:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.btn-submit {
    padding: 10px 28px;
    background: var(--green);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn-submit:hover {
    background: #16a34a;
    transform: translateY(-1px);
}

.btn-submit:active {
    transform: translateY(0);
}

.btn-submit:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.submit-result {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.88em;
    font-weight: 600;
    display: none;
}

.submit-result.success {
    display: block;
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.submit-result.error {
    display: block;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* ══════════════ 토스트 알림 ══════════════ */
.toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: #1a1a2e;
    color: #fff;
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 0.88em;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateY(12px);
    z-index: 2000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    border-left: 4px solid var(--green);
}

.toast.error {
    border-left: 4px solid var(--red);
}

/* ══════════════ 회원가입 버튼 ══════════════ */
.btn-signup {
    width: 100%;
    padding: 7px;
    background: transparent;
    color: #58a6ff;
    border: 1px solid #3b82f6;
    border-radius: 8px;
    font-size: 0.8em;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
    transition: all 0.15s;
}

.btn-signup:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* ══════════════ 관리자 nav ══════════════ */
.nav-item-admin {
    background: rgba(239, 68, 68, 0.07);
    border: 1px dashed #ef4444;
    color: #f87171 !important;
}

/* ══════════════ 데이터 게이트 오버레이 ══════════════ */
.gate-overlay {
    position: fixed;
    inset: 0;
    background: rgba(240, 242, 245, 0.96);
    backdrop-filter: blur(6px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: var(--sidebar-w);
}

.gate-box {
    text-align: center;
    padding: 40px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
    max-width: 420px;
}

.gate-icon {
    font-size: 3em;
    margin-bottom: 12px;
}

.gate-title {
    font-size: 1.3em;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 10px;
}

.gate-desc {
    font-size: 0.9em;
    color: var(--text-sub);
    margin-bottom: 24px;
    line-height: 1.6;
}

.gate-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-gate-signup {
    padding: 10px 22px;
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
    border-radius: 10px;
    font-size: 0.92em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-gate-signup:hover {
    background: var(--accent);
    color: #fff;
}

/* ══════════════ 섹션 서브타이틀 ══════════════ */
.section-subtitle {
    font-size: 1em;
    font-weight: 700;
    color: var(--text-main);
    margin: 28px 0 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--orange);
    display: inline-block;
}

/* ══════════════ 관리자 패널 ══════════════ */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.78em;
    font-weight: 700;
}

.status-approved {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.status-pending {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.status-rejected {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.status-admin {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.btn-approve {
    padding: 4px 12px;
    background: var(--green);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.78em;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    margin-right: 4px;
}

.btn-approve:hover {
    background: #16a34a;
}

.btn-reject {
    padding: 4px 12px;
    background: #fff;
    color: var(--red);
    border: 1px solid var(--red);
    border-radius: 6px;
    font-size: 0.78em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    margin-right: 4px;
}

.btn-reject:hover {
    background: var(--red);
    color: #fff;
}

.btn-del-user {
    padding: 4px 10px;
    background: #fff;
    color: #6b7280;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.75em;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-del-user:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #dc2626;
}

.btn-refresh {
    padding: 6px 14px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.82em;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-refresh:hover {
    background: #f8fafc;
    border-color: var(--accent);
}

/* ══════════════ 삭제 버튼 (이력 테이블) ══════════════ */
.btn-del-report {
    padding: 3px 10px;
    background: #fff;
    color: var(--red);
    border: 1px solid #fecaca;
    border-radius: 6px;
    font-size: 0.75em;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-del-report:hover {
    background: var(--red);
    color: #fff;
}

/* ══════════════ 8-CAR TRAIN UI ══════════════ */
.train-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
}

.train-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.train-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
}

.train-visual {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 0;
    overflow-x: auto;
}

.train-car {
    flex: 1;
    min-width: 60px;
    height: 45px;
    background: #fff;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.train-car:hover {
    border-color: var(--accent);
    background: #f1f5f9;
    transform: translateY(-2px);
}

.train-car.has-fault {
    border-color: #f87171;
    background: #fef2f2;
}

.train-car.selected {
    border-color: var(--accent);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.car-num {
    font-size: 0.75rem;
    font-weight: 800;
    color: #64748b;
}

.train-car.has-fault .car-num {
    color: #ef4444;
}

.car-fault-count {
    font-size: 0.65rem;
    background: #ef4444;
    color: #fff;
    padding: 1px 4px;
    border-radius: 4px;
    position: absolute;
    top: -8px;
    right: -4px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.train-head-l {
    border-top-left-radius: 20px;
    border-bottom-left-radius: 10px;
    background: #e2e8f0;
}

.train-head-r {
    border-top-right-radius: 20px;
    border-bottom-right-radius: 10px;
    background: #e2e8f0;
}

.car-details {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.82rem;
    display: none;
}

.car-details.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.car-fault-item {
    padding: 6px 0;
    border-bottom: 1px solid #f1f5f9;
}

.car-fault-item:last-child {
    border-bottom: none;
}

.car-fault-date {
    font-weight: 700;
    color: #64748b;
    margin-right: 8px;
}

/* ══════════════ 엑셀 Export 버튼 ══════════════ */
.btn-export {
    padding: 9px 18px;
    color: #fff;
    border: none;
    border-radius: 9px;
    font-size: 0.85em;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: opacity 0.15s, transform 0.12s;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.btn-export:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.btn-export:active {
    transform: translateY(0);
    opacity: 1;
}

/* 자재 반출내역 관련 스타일 */
.overdue-row {
    background-color: #fff1f2 !important;
}
.overdue-row td {
    color: #be123c !important;
}
.text-red {
    color: #ef4444;
}
.font-bold {
    font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════
   심층 분석 (Advanced Analysis) 스타일
   ═══════════════════════════════════════════════════════════ */
.heatmap-grid {
    display: grid;
    grid-template-columns: 120px repeat(12, 1fr);
    gap: 2px;
    background: #e5e7eb;
    border: 1px solid #e5e7eb;
    min-width: 800px;
}

.heatmap-cell {
    background: #fff;
    padding: 8px 4px;
    text-align: center;
    font-size: 0.8em;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #374151;
    position: relative;
    transition: transform 0.1s;
    min-height: 36px;
}

.heatmap-cell:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    border-radius: 4px;
}

.heatmap-header-y {
    font-weight: 600;
    background: #f9fafb;
    justify-content: flex-start;
    padding-left: 8px;
}

.heatmap-header-x {
    font-weight: 600;
    background: #f9fafb;
}

.predictive-progress-bg {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

.predictive-progress-fill {
    height: 100%;
    transition: width 0.5s ease-out;
}

/* ══════════════ AI AGENT & UPLOADER UI ══════════════ */
.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: #64748b;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

.tab-btn.active {
    border-bottom: 2px solid var(--accent);
    color: var(--accent);
    background: #ffffff;
}

.upload-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.upload-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Chat Styling */
.chat-bubble-user {
    align-self: flex-end;
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px 12px 0 12px;
    background: var(--accent);
    color: #ffffff;
    font-size: 0.88rem;
    box-shadow: 0 2px 4px rgba(59,130,246,0.25);
    word-break: break-all;
    line-height: 1.45;
}

.chat-bubble-agent {
    align-self: flex-start;
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 12px 12px 12px 0;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    font-size: 0.88rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    line-height: 1.6;
    color: #1e293b;
    word-break: break-word;
}

/* Markdown parsing output styling */
.chat-bubble-agent h3, .chat-bubble-agent h4 {
    margin-top: 10px;
    margin-bottom: 6px;
    color: #0f172a;
    font-weight: 700;
}
.chat-bubble-agent p {
    margin-bottom: 8px;
}
.chat-bubble-agent ul, .chat-bubble-agent ol {
    margin-left: 20px;
    margin-bottom: 8px;
}
.chat-bubble-agent table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.82rem;
}
.chat-bubble-agent th, .chat-bubble-agent td {
    border: 1px solid #cbd5e1;
    padding: 6px 8px;
    text-align: left;
}
.chat-bubble-agent th {
    background: #f1f5f9;
    font-weight: 700;
}
.chat-bubble-agent blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 10px;
    color: #475569;
    background: #f8fafc;
    margin: 8px 0;
    font-style: italic;
}

/* Manuals Tree View */
.manual-folder-node {
    font-weight: 700;
    color: #334155;
    margin: 4px 0;
    cursor: pointer;
    user-select: none;
}
.manual-file-node {
    margin-left: 18px;
    padding: 2px 0;
    color: #0284c7;
    cursor: pointer;
}
.manual-file-node:hover {
    text-decoration: underline;
}