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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #1a1a2e;
    line-height: 1.5;
}

header {
    background: #1a1a2e;
    color: #fff;
    padding: 0.8rem 2rem;
    display: flex;
    align-items: baseline;
    gap: 1rem;
}
header h1 { font-size: 1.3rem; font-weight: 600; }
header span { font-size: 0.85rem; opacity: 0.6; flex: 1; }
header .gh-link {
    color: rgba(255,255,255,0.6);
    transition: color 0.15s;
    display: flex;
    align-items: center;
}
header .gh-link:hover { color: #fff; }

footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.78rem;
    color: #888;
}
footer a { color: #4361ee; text-decoration: none; }
footer a:hover { text-decoration: underline; }

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1rem;
    height: calc(100vh - 50px);
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

.main-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

.panel {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.panel h2 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #555;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #e8ecf1;
}

.plot-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.plot-panel h2 { flex-shrink: 0; }

/* Drop zone */
.drop-zone {
    border: 2px dashed #c5cdd8;
    border-radius: 6px;
    padding: 1.2rem 0.8rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0.75rem;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: #4361ee;
    background: #f0f4ff;
}
.drop-zone p { font-size: 0.8rem; color: #666; }
.drop-zone .formats { font-size: 0.7rem; color: #999; margin-top: 0.15rem; }
.drop-zone input[type="file"] { display: none; }

.demo-link {
    font-size: 0.75rem;
    color: #888;
    text-align: center;
    margin-bottom: 0.5rem;
}
.demo-link a {
    color: #4361ee;
    text-decoration: none;
}
.demo-link a:hover {
    text-decoration: underline;
}

.file-info {
    font-size: 0.78rem;
    color: #4361ee;
    margin-bottom: 0.75rem;
    padding: 0.4rem 0.6rem;
    background: #f0f4ff;
    border-radius: 4px;
    display: none;
}
.file-info.visible { display: block; }

/* Form controls */
.form-group {
    margin-bottom: 0.6rem;
}
.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
    color: #555;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid #d1d9e6;
    border-radius: 4px;
    font-size: 0.82rem;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #4361ee;
    box-shadow: 0 0 0 2px rgba(67,97,238,0.15);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}


.btn {
    display: block;
    width: 100%;
    padding: 0.55rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 0.75rem;
}
.btn-primary {
    background: #4361ee;
    color: #fff;
}
.btn-primary:hover { background: #3a56d4; }
.btn-primary:disabled {
    background: #a0b0d0;
    cursor: not-allowed;
}

/* Results */
.result-badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.result-badge.success { background: #d4edda; color: #155724; }

.result-badge.error { background: #f8d7da; color: #721c24; }

/* Coupling matrix */
.cm-table {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 300px;
}
.cm-table table {
    border-collapse: collapse;
    width: 100%;
}
.cm-table th {
    padding: 0.35rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #888;
    text-align: center;
    border-bottom: 2px solid #dde3ec;
    position: sticky;
    top: 0;
    background: #fff;
}
.cm-table td {
    padding: 0.3rem 0.5rem;
    font-size: 0.78rem;
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid #f0f2f5;
}
.cm-table tr:hover td {
    background: #f8f9fb;
}
.cm-table td.row-header {
    font-weight: 600;
    color: #888;
    text-align: center;
    font-size: 0.7rem;
    border-right: 2px solid #dde3ec;
}
.cm-table td.zero {
    color: #ccc;
}
.cm-table td.diagonal {
    background: #f0f4ff;
    font-weight: 500;
}
.cm-table td.coupling {
    color: #1a1a2e;
}

/* Plot area */
.plot-area {
    flex: 1;
    min-height: 500px;
}

#status {
    font-size: 0.78rem;
    color: #888;
    margin-top: 0.4rem;
    min-height: 1.2em;
}
#status.running { color: #e67e22; }
#status.error { color: #e74c3c; }

/* Responsive */
@media (max-width: 900px) {
    .container {
        grid-template-columns: 1fr;
        height: auto;
    }
    .plot-area {
        min-height: 350px;
    }
}
