:root {
    --bg-color: #0d1117;
    --panel-bg: rgba(22, 27, 34, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;

    --accent-blue: #2f81f7;
    --accent-blue-hover: #1f6feb;
    --accent-green: #238636;
    --accent-red: #da3633;
    --accent-orange: #d29922;

    --positive: #3fb950;
    --negative: #f85149;
    --warning: #d29922;

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --radius-lg: 16px;
    --radius-md: 8px;
    --radius-sm: 4px;
    --transition: 0.3s ease;

    --glass-blur: blur(12px);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(47, 129, 247, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(218, 54, 51, 0.05), transparent 25%);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.app-container {
    display: flex;
    gap: 24px;
    width: 100%;
    max-width: 1400px;
    height: 90vh;
    max-height: 900px;
}

.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.sidebar {
    flex: 0 0 380px;
    display: flex;
    gap: 24px;
    overflow-y: auto;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
    background: linear-gradient(90deg, #fff, #8b949e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

.control-group {
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.control-group>label:not(.control-label) {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.control-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.range-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 0 10px rgba(47, 129, 247, 0.5);
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.value-display {
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 45px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.state-selector {
    margin-bottom: 24px;
}

.state-selector label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.glass-select {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.primary-btn {
    background: var(--accent-blue);
    color: white;
    box-shadow: 0 4px 14px rgba(47, 129, 247, 0.3);
}

.primary-btn:hover {
    background: var(--accent-blue-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(47, 129, 247, 0.4);
}

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

.icon-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    flex-direction: row;
}

.header-titles h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-titles .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
    font-weight: 500;
}

.pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 1);
    transform: scale(1);
    animation: pulse 2s infinite;
}

.pulse.normal {
    background: var(--positive);
    box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.7);
}

.pulse.warning {
    background: var(--warning);
    box-shadow: 0 0 0 0 rgba(210, 153, 34, 0.7);
}

.pulse.danger {
    background: var(--negative);
    box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.7);
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 currentcolor;
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(0, 0, 0, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
    }
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.metric-card {
    position: relative;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.metric-card:hover {
    transform: translateY(-4px);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
    opacity: 0.5;
}

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

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.value {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.highlight-positive {
    color: var(--positive);
}

.highlight-negative {
    color: var(--negative);
}

.formula-breakdown {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.formula-breakdown span {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.action-display {
    text-align: center;
    padding: 32px;
}

.action-display h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.action-result {
    font-size: 1.5rem;
    font-weight: 600;
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    transition: all 0.5s ease;
}

.action-result.stop {
    background: rgba(248, 81, 73, 0.1);
    color: var(--negative);
    border-color: rgba(248, 81, 73, 0.3);
    box-shadow: inset 0 0 20px rgba(248, 81, 73, 0.05);
}

.action-result.continue {
    background: rgba(63, 185, 80, 0.1);
    color: var(--positive);
    border-color: rgba(63, 185, 80, 0.3);
    box-shadow: inset 0 0 20px rgba(63, 185, 80, 0.05);
}

.placeholder-text {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 1rem;
}

.log-container {
    flex: 1;
    display: flex;
    padding: 16px 24px;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.log-header h3 {
    font-size: 1rem;
    color: var(--text-secondary);
}

#simulation-log {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 8px;
}

.log-entry {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    animation: fadeIn 0.3s ease;
    border-left: 3px solid transparent;
}

.log-entry.system {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.log-entry.decision-stop {
    background: rgba(248, 81, 73, 0.05);
    border-left-color: var(--negative);
}

.log-entry.decision-continue {
    background: rgba(63, 185, 80, 0.05);
    border-left-color: var(--positive);
}

.log-entry .timestamp {
    color: var(--text-secondary);
    margin-right: 8px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        height: auto;
        max-height: none;
    }

    .sidebar {
        flex: none;
        max-height: 400px;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: rgba(22, 27, 34, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    overflow-y: auto;
    padding-right: 16px;
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-body h4 {
    color: var(--text-primary);
    font-size: 1.2rem;
    margin-top: 24px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 8px;
}

.modal-body p {
    margin-bottom: 16px;
}

.modal-body strong {
    color: var(--text-primary);
}