/* ═══ 크라우니 INT 통합관제 스타일 ═══ */
:root {
    --bg: #0a0e17;
    --bg2: #111827;
    --bg3: #1f2937;
    --text: #e5e7eb;
    --text2: #9ca3af;
    --border: #374151;
    --accent: #3b82f6;
    --green: #10b981;
    --yellow: #f59e0b;
    --orange: #f97316;
    --red: #ef4444;
    --darkred: #b91c1c;
    --purple: #8b5cf6;
    --gray: #6b7280;
    --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, 'Noto Sans KR', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ═══ 헤더 ═══ */
header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; height: 56px;
    background: var(--bg2); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 22px; font-weight: 900; color: var(--red); letter-spacing: 2px; }
.subtitle { font-size: 13px; color: var(--text2); }
.header-nav { display: flex; gap: 4px; }
.nav-btn {
    background: none; border: none; color: var(--text2); padding: 8px 16px;
    font-size: 14px; cursor: pointer; border-radius: var(--radius);
    transition: all .2s;
}
.nav-btn:hover { background: var(--bg3); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; }
.header-right { display: flex; align-items: center; gap: 16px; }
.alert-indicator {
    display: flex; align-items: center; gap: 6px; padding: 4px 12px;
    background: var(--bg3); border-radius: 20px; font-size: 13px;
}
.alert-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.alert-dot.active { background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.clock { font-size: 14px; color: var(--text2); font-variant-numeric: tabular-nums; }

/* ═══ 메인 ═══ */
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; }

/* ═══ 도메인 그리드 ═══ */
.domain-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.domain-card {
    background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; cursor: pointer; transition: all .2s;
    position: relative; overflow: hidden;
}
.domain-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.domain-card .level-bar {
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.domain-card h3 { font-size: 16px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.domain-card .domain-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.domain-card .stats { display: flex; gap: 16px; margin-top: 12px; }
.domain-card .stat { font-size: 12px; color: var(--text2); }
.domain-card .stat strong { font-size: 20px; color: var(--text); display: block; }
.domain-card .alert-label {
    position: absolute; top: 16px; right: 16px;
    padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600;
}

/* ═══ 패널 ═══ */
.panel {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
}
.panel h3 { font-size: 14px; color: var(--text2); margin-bottom: 12px; }
.dashboard-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ═══ 이벤트/경보 리스트 ═══ */
.event-item, .alert-item {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 18px;
    margin-bottom: 8px; display: flex; align-items: center; gap: 14px;
    transition: all .2s;
}
.event-item:hover, .alert-item:hover { border-color: var(--accent); }
.event-item .level-badge, .alert-item .level-badge {
    min-width: 40px; height: 40px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; color: #fff;
}
.event-item .info, .alert-item .info { flex: 1; }
.event-item .title, .alert-item .title { font-size: 14px; font-weight: 600; }
.event-item .meta, .alert-item .meta { font-size: 12px; color: var(--text2); margin-top: 4px; }
.event-item .actions, .alert-item .actions { display: flex; gap: 8px; }

/* ═══ 버튼 ═══ */
.btn {
    padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg3); color: var(--text); font-size: 13px; cursor: pointer;
    transition: all .2s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: var(--darkred); }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }

/* ═══ 필터/헤더 ═══ */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-header h2 { font-size: 20px; }
.filters { display: flex; gap: 8px; align-items: center; }
select {
    padding: 6px 10px; background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 13px;
}

/* ═══ 셀 그래프 ═══ */
#cellCanvas { width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); }
.cell-info-panel {
    margin-top: 12px; background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; display: none;
}
.cell-info-panel.visible { display: block; }

/* ═══ 시나리오 ═══ */
.scenario-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.scenario-card {
    background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; cursor: pointer; transition: all .2s;
}
.scenario-card:hover { border-color: var(--accent); }
.scenario-card h4 { margin-bottom: 6px; }
.scenario-card .desc { font-size: 13px; color: var(--text2); margin-bottom: 10px; }
.scenario-card .sc-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text2); }
.scenario-detail { margin-top: 16px; }

.result-step { padding: 10px 14px; border-left: 3px solid var(--border); margin-bottom: 6px; background: var(--bg3); border-radius: 0 var(--radius) var(--radius) 0; }
.result-step.passed { border-left-color: var(--green); }
.result-step.failed { border-left-color: var(--red); }
.result-step .step-name { font-weight: 600; font-size: 13px; }
.result-step .step-detail { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* ═══ 모달 ═══ */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.visible { display: flex; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; width: 520px; max-width: 90vw; max-height: 80vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-close { background: none; border: none; color: var(--text2); font-size: 24px; cursor: pointer; }
.modal-body { padding: 20px; }
.modal-body label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 4px; margin-top: 12px; }
.modal-body input, .modal-body select, .modal-body textarea {
    width: 100%; padding: 8px 12px; background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 14px;
}
.modal-body .form-actions { display: flex; gap: 8px; margin-top: 20px; justify-content: flex-end; }

/* ═══ 레벨 색상 ═══ */
.level-0 { background: var(--green); }
.level-1 { background: var(--yellow); }
.level-2 { background: var(--orange); }
.level-3 { background: var(--red); }
.level-4 { background: var(--darkred); }

.state-U { color: var(--gray); }
.state-O { color: var(--yellow); }
.state-T { color: var(--red); }
.state-A { color: var(--text2); text-decoration: line-through; }

/* ═══ 반응형 ═══ */
@media (max-width: 900px) {
    .domain-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-bottom { grid-template-columns: 1fr; }
    .scenario-list { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .domain-grid { grid-template-columns: 1fr; }
    .header-nav { display: none; }
}
