/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-page, #f1f5f9);
    color: var(--text-primary, #1e293b);
    line-height: 1.5;
    padding: 0;
    margin: 0;
}

/* Header */
.lab-header {
    background-color: #0f172a;
    color: #ffffff;
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-title h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.2rem;
}

.badge {
    background-color: #3b82f6;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.mode-selector {
    display: flex;
    background-color: #1e293b;
    padding: 4px;
    border-radius: 8px;
    gap: 4px;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-mode {
    background: transparent;
    color: #94a3b8;
}

.btn-mode.active {
    background-color: #2563eb;
    color: #ffffff;
}

.btn-reset {
    background-color: #ef4444;
    color: #ffffff;
}

.btn-reset:hover {
    background-color: #dc2626;
}

.btn-primary {
    background-color: #2563eb;
    color: #ffffff;
    flex: 1;
    justify-content: center;
    padding: 0.65rem 1rem;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: #64748b;
    color: #ffffff;
    padding: 0.65rem 1rem;
}

.btn-secondary:hover {
    background-color: #475569;
}

/* Main Layout Grid */
.main-layout {
    max-width: 1400px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Cards */
.card, .sim-card {
    background: var(--bg-card, #ffffff);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
    padding: 1.25rem;
    border: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-primary, #0f172a);
}

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

.card-header h2, .card-header h3, .card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary, #0f172a);
}

/* Elastic Region Status Badge */
.elastic-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.elastic-ok {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.elastic-ok .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #22c55e;
}

.elastic-warning {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    animation: pulse 1.5s infinite;
}

.elastic-warning .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ef4444;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* SVG Simulator Container */
.svg-container {
    width: 100%;
    height: 600px;
    background-color: var(--bg-main, #fafafa);
    border-radius: 8px;
    border: 1px solid var(--border-color, #cbd5e1);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.svg-container svg {
    width: 100%;
    height: 100%;
}

.ruler-title {
    font-size: 11px;
    font-weight: 700;
    fill: var(--text-secondary, #475569);
}

/* Controls Column */
.controls-column {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Live Measurements Dashboard */
.measurements-card h3 {
    margin-bottom: 0.8rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.metric-box {
    background-color: var(--bg-subtle, #f8fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    padding: 0.75rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.metric-box.highlight-ext {
    background-color: rgba(37, 99, 235, 0.12);
    border-color: var(--accent, #3b82f6);
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.metric-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary, #0f172a);
}

.metric-value small {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted, #64748b);
}

.verification-box {
    align-items: center;
    justify-content: center;
}

.verification-tag {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.verification-tag.verified {
    background-color: #dcfce7;
    color: #15803d;
}

/* Controls Card */
.control-group {
    margin-bottom: 1.25rem;
}

.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.control-header label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary, #334155);
}

.number-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input, #f8fafc);
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 6px;
    padding: 0.2rem 0.5rem;
}

.number-input-wrap input {
    width: 60px;
    border: none;
    background: transparent;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary, #0f172a);
    text-align: right;
    outline: none;
}

.number-input-wrap .unit {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    margin-left: 0.3rem;
}

.slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e2e8f0;
    outline: none;
    accent-color: #2563eb;
    cursor: pointer;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.2rem;
}

.action-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* Graph Canvas */
.canvas-container {
    width: 100%;
    height: 250px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    position: relative;
}

#graphCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Bottom Section (Table + Theory) */
.bottom-section {
    max-width: 1400px;
    margin: 0 auto 2rem auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.table-subtitle {
    font-size: 0.8rem;
    color: #64748b;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

th, td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
}

td {
    font-family: 'JetBrains Mono', monospace;
}

tbody tr:hover {
    background-color: #f1f5f9;
}

/* Theory Section */
.theory-card h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: #0f172a;
}

.theory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.theory-block {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
}

.theory-block h3 {
    font-size: 1rem;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.theory-block p, .theory-block ul, .theory-block ol {
    font-size: 0.875rem;
    color: #475569;
}

.theory-block ul, .theory-block ol {
    padding-left: 1.2rem;
}

.formula-box {
    background-color: #0f172a;
    color: #38bdf8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    padding: 0.6rem;
    border-radius: 6px;
    margin: 0.6rem 0;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .header-container {
        flex-direction: column;
        align-items: flex-start;
    }
}
