* { box-sizing: border-box; user-select: none; }
body {
    background: #e2e8f0;
    font-family: 'Segoe UI', Roboto, 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    margin: 0;
}
.simulator {
    max-width: 1700px;
    width: 100%;
    background: #f8fafc;
    border-radius: 2rem;
    box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}
.header {
    background: #0f172a;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
}
.title { font-size: 1.6rem; font-weight: 700; }
.title small { font-size: 0.8rem; background: #334155; padding: 2px 8px; border-radius: 20px; margin-left: 10px; }
.brand { font-size: 0.85rem; background: #1e293b; padding: 5px 12px; border-radius: 30px; }
.nav-tools {
    background: #f0f4f9;
    padding: 10px 20px;
    border-radius: 48px;
    margin: 12px 20px 0 20px;
    display: flex;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.nav-tools a {
    background: #e2eaf1;
    padding: 6px 18px;
    border-radius: 40px;
    text-decoration: none;
    color: #1a5d8c;
    font-weight: 500;
    transition: 0.2s;
}
.nav-tools a:hover {
    background: #cbdde9;
    transform: translateY(-1px);
}
.dashboard {
    display: flex;
    flex-wrap: wrap;
    padding: 1.5rem;
    gap: 1.5rem;
}
.single-line {
    flex: 2.4;
    min-width: 780px;
    background: #ffffff;
    border-radius: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    padding: 1.2rem;
    border: 1px solid #e2e8f0;
}
.diagram-title {
    font-weight: 700;
    margin-bottom: 1rem;
    color: #1e293b;
    border-left: 5px solid #3b82f6;
    padding-left: 12px;
    font-size: 1.3rem;
}
.schematic-container {
    background: #fefcf5;
    border-radius: 20px;
    padding: 12px;
    margin-bottom: 24px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    position: relative;
}
canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #cbd5e1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.legacy-animation-area {
    margin-top: 12px;
}
.source-row {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 12px;
    background: #f1f5f9;
    padding: 12px;
    border-radius: 1rem;
    margin-bottom: 12px;
}
.source-item {
    text-align: center;
    min-width: 130px;
    background: #fefce8;
    padding: 10px;
    border-radius: 20px;
    transition: all 0.2s;
    font-size: 0.95rem;
    font-weight: 500;
}
.switch-badge {
    background: #1e293b;
    color: white;
    font-weight: bold;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-top: 6px;
    display: inline-block;
}
.current-flow-line {
    height: 6px;
    background: #cbd5e1;
    border-radius: 4px;
    margin: 8px 0;
    width: 100%;
}
.flow-active-glow { background: linear-gradient(90deg, #10b981, #facc15, #10b981); background-size: 200% 100%; animation: flowLightReverse 2.5s linear infinite; }
.flow-active-blue { background: linear-gradient(90deg, #3b82f6, #60a5fa, #3b82f6); background-size: 200% 100%; animation: flowLightReverse 2.2s linear infinite; }
.flow-active-orange { background: linear-gradient(90deg, #f97316, #fbbf24, #f97316); background-size: 200% 100%; animation: flowLightReverse 2.8s linear infinite; }
@keyframes flowLightReverse {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
.moving-particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffdd55;
    border-radius: 50%;
    box-shadow: 0 0 8px #ffaa00;
    top: -2px;
    right: 0;
    animation: pulseMoveReverse 2.5s ease-in-out infinite;
}
@keyframes pulseMoveReverse {
    0% { transform: translateX(15px); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateX(-60px); opacity: 0; }
}
.particle-container { position: relative; width: 100%; height: 5px; margin: 4px 0; }
.component-block { background: white; border-radius: 16px; padding: 10px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.1); border: 1px solid #cbd5e1; font-size: 0.95rem; font-weight: 500;}
.inv-block { background: #eef2ff; border-left: 4px solid #3b82f6; }
.power-flow { display: flex; align-items: center; justify-content: center; gap: 20px; flex-wrap: wrap; margin: 20px 0; background: #fef9e3; padding: 12px; border-radius: 2rem; }
.current-mode { background: #dbeafe; border: 1px solid #3b82f6; margin-top: 1rem; text-align: center; padding: 14px; border-radius: 2rem; font-weight: bold; font-size: 1.05rem; }
.status-row { display: flex; justify-content: space-between; background: #f8fafc; padding: 10px 16px; border-radius: 50px; margin-top: 12px; font-size: 0.9rem; font-weight: 500; }
.status-led { width: 15px; height: 15px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.led-green { background-color: #10b981; box-shadow: 0 0 4px #10b981; }
.led-gray { background-color: #94a3b8; }
.epo-alert { background: #fee2e2; border-left: 4px solid #dc2626; padding: 8px; border-radius: 12px; font-weight: bold; margin-top: 10px; font-size: 0.9rem; }
.battery-warning {
    background: #dc2626;
    color: white;
    font-weight: bold;
    text-align: center;
    padding: 6px;
    border-radius: 20px;
    margin-top: 8px;
    animation: blinkWarning 1s infinite;
    font-size: 0.85rem;
}
@keyframes blinkWarning {
    0% { opacity: 0.7; background: #dc2626; }
    50% { opacity: 1; background: #b91c1c; box-shadow: 0 0 6px red; }
    100% { opacity: 0.7; background: #dc2626; }
}
.button-panel {
    flex: 1;
    min-width: 320px;
    background: #ffffff;
    border-radius: 1.5rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.mode-group {
    background: #f1f5f9;
    border-radius: 1rem;
    padding: 0.8rem;
}
.mode-group .title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 10px;
    color: #1e293b;
    border-left: 3px solid #3b82f6;
    padding-left: 8px;
}
.btn-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.mode-btn, .btn {
    border: none;
    padding: 8px 6px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.1s;
    background: #e2e8f0;
    color: #1e293b;
}
.mode-btn:active, .btn:active { transform: scale(0.96); }
.mode-btn-primary { background: #2563eb; color: white; }
.mode-btn-warning { background: #f59e0b; color: white; }
.mode-btn-danger { background: #dc2626; color: white; }
.mode-btn-secondary { background: #475569; color: white; }
.btn-primary { background: #2563eb; color: white; }
.btn-danger { background: #dc2626; color: white; }
.btn-warning { background: #f59e0b; color: white; }
.btn-secondary { background: #475569; color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.log-area {
    flex: 1;
    min-width: 280px;
    background: #fef9e3;
    border-radius: 1.5rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}
.log-header { font-weight: bold; border-bottom: 2px solid #facc15; padding-bottom: 8px; margin-bottom: 12px; display: flex; justify-content: space-between; font-size: 1rem; }
.log-list { max-height: 320px; overflow-y: auto; font-size: 0.85rem; font-family: monospace; }
.log-item { padding: 6px 0; border-bottom: 1px solid #fde68a; }
.clear-log { background: none; border: none; color: #f97316; cursor: pointer; font-weight: bold; }
footer { background: #e6f0ff; text-align: center; padding: 12px; font-size: 0.85rem; color: #334155; }
.time-slider {
    background: #f1f5f9;
    border-radius: 1rem;
    padding: 10px 12px;
    margin-top: 8px;
}
.time-slider label {
    font-weight: bold;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 6px;
}
.time-slider input {
    width: 100%;
    cursor: pointer;
}
.time-value {
    font-size: 0.9rem;
    text-align: center;
    margin-top: 5px;
    font-weight: 600;
    color: #2563eb;
}
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20000;
    backdrop-filter: blur(5px);
    animation: fadeInOverlay 0.3s ease-out;
}
.modal-box {
    background: #dc2626;
    color: white;
    padding: 2rem 3rem;
    border-radius: 2rem;
    text-align: center;
    animation: pulseAlert 0.5s ease-in-out infinite alternate;
    box-shadow: 0 25px 40px rgba(0,0,0,0.5);
    border: 4px solid #facc15;
    max-width: 90%;
    width: 500px;
}
.modal-box h1 { font-size: 2rem; margin: 0 0 1rem 0; }
.modal-box p { font-size: 1.2rem; margin: 0.5rem 0; font-weight: bold; }
.modal-box .sub-text { font-size: 1rem; opacity: 0.9; margin-bottom: 1.5rem; }
.modal-box button {
    background: white;
    color: #dc2626;
    border: none;
    padding: 12px 28px;
    border-radius: 60px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
}
@keyframes pulseAlert {
    0% { transform: scale(1); background-color: #dc2626; border-color: #facc15; }
    100% { transform: scale(1.02); background-color: #b91c1c; border-color: #fffbeb; }
}
@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}
@media (max-width: 1200px) { .single-line { min-width: auto; } .dashboard { flex-direction: column; } }