:root {
    --bg: #f8f9fa;
    --card: #ffffff;
    --border: #dadce0;
    --text-main: #202124;
    --text-muted: #5f6368;
    --primary: #4285f4;
    --danger: #ea4335;
    --normal: #0f9d58;
    --target: #a142f4;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Noto Sans SC", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text-main);
    line-height: 1.6;
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
}

.hero {
    background: var(--card);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.hero h1 {
    margin: 0 0 12px;
    font-size: 24px;
    color: #1a73e8;
}

.hero p {
    margin: 0;
    color: var(--text-muted);
}

.dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

@media (min-width: 900px) {
    .dashboard {
        flex-direction: row;
        align-items: stretch;
    }

    .network-panel {
        flex: 3;
    }

    .controls {
        flex: 2;
        width: 380px;
        flex-shrink: 0;
    }
}

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.network-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.network-header h2 {
    margin: 0;
    font-size: 18px;
}

.legend {
    display: flex;
    gap: 12px;
    font-size: 13px;
}

.badge.normal {
    color: var(--normal);
    font-weight: 600;
}

.badge.suspicious {
    color: var(--danger);
    font-weight: 600;
}

.badge.target {
    color: var(--target);
    font-weight: 600;
}

.chart-container {
    flex-grow: 1;
    min-height: 500px;
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.controls h2 {
    margin: 0 0 20px 0;
    font-size: 18px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.controls h3 {
    margin: 0 0 10px 0;
    font-size: 15px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.stat-box {
    background: #f1f3f4;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}

.stat-title {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
}

.metric-explain {
    background: #e8f0fe;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-size: 13.5px;
}

.metric-explain h3 {
    color: #1a73e8;
}

.metric-explain ul {
    margin: 0;
    padding-left: 20px;
}

.metric-explain li {
    margin-bottom: 6px;
}

.filter-console {
    background: #fff;
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 8px;
}

.console-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: -4px;
    margin-bottom: 16px;
}

.filter-group {
    margin-bottom: 16px;
}

.filter-group label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
}

.filter-group input[type="range"] {
    width: 100%;
    accent-color: var(--danger);
}

.help-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.btn.primary {
    background: var(--danger);
    color: white;
}

.btn.primary:hover {
    background: #d93025;
}

.btn.secondary {
    background: transparent;
    color: #3c4043;
}

.btn.outline {
    border: 1px solid var(--border);
}

.btn.outline:hover {
    background: #f8f9fa;
}

.status-msg {
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
}

/* === Dark Mode Override (auto-generated) === */
:root[data-theme="dark"] {
  --bg: #1a1a2e;
  --card: #242438;
  --border: #3a3a50;
  --text-main: #e8e8f0;
  --text-muted: #aaa;
  --primary: #9b7bff;
  --danger: #f87171;
  --normal: #aaaabc;
  --target: #aaaabc;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #1a1a2e;
  --card: #242438;
  --border: #3a3a50;
  --text-main: #e8e8f0;
  --text-muted: #aaa;
  --primary: #9b7bff;
  --danger: #f87171;
  --normal: #aaaabc;
  --target: #aaaabc;
  }
}

/* === CSS Professor Animation Upgrade (Round 22) === */

/* Page entrance */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.app, main, body > .container { animation: fadeInUp 0.4s ease-out; }

/* Staggered card entrance */
@keyframes cardReveal {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.card, [class*="card"], .mission-card, .module-card, .stat-card {
  animation: cardReveal 0.35s ease-out both;
}
.card:nth-child(2), [class*="card"]:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3), [class*="card"]:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4), [class*="card"]:nth-child(4) { animation-delay: 0.15s; }
.card:nth-child(5), [class*="card"]:nth-child(5) { animation-delay: 0.2s; }

/* Subtle pulse for primary buttons */
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
  50% { box-shadow: 0 2px 12px rgba(199,73,31,0.25); }
}
button[id*="Btn"]:not(:disabled), .btn-primary {
  animation: btnPulse 3s ease-in-out infinite;
}
button:disabled { animation: none; opacity: 0.6; }

/* Smooth height transitions for collapsible sections */
details { transition: all 0.2s ease; }
details[open] summary { margin-bottom: 8px; }

/* Tooltip fade */
[title] { position: relative; }

/* Progress bar animation */
@keyframes progressFill {
  from { width: 0; }
}
.mc-bar-fill, .mod-progress-fill, .bar-fill, progress::-webkit-progress-value {
  animation: progressFill 0.6s ease-out;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === Loading & Feedback States === */
@keyframes spin { to { transform: rotate(360deg); } }
.btn-loading { position: relative; pointer-events: none; opacity: 0.7; }
.btn-loading::after {
  content: '';
  position: absolute;
  right: 8px; top: 50%;
  width: 14px; height: 14px;
  margin-top: -7px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.toast-msg {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 0.9rem; z-index: 9999; opacity: 0;
  transition: opacity 0.3s ease;
}
.toast-msg.show { opacity: 1; }
