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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 100%);
    color: #ffffff;
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.header {
    background: #61180f;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.header h1 {
    font-size: 2.2em;
    margin-bottom: 5px;
}

.subtitle {
    color: #ffcccc;
    font-size: 1.1em;
}

.logo {
    margin-bottom: 10px;
}

.connection-status {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    z-index: 1000;
    background: #4CAF50;
    color: white;
}

.connection-status.disconnected {
    background: #f44336;
}

/* Aggregated Stats Section */
.aggregated-stats {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border: 2px solid #61180f;
}

.aggregated-stats h2 {
    color: #ff6b4a;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.08);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #ff6b4a;
}

.stat-label {
    font-size: 0.9em;
    color: #cccccc;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #ffffff;
}

.stat-unit {
    font-size: 0.8em;
    color: #aaaaaa;
    margin-left: 5px;
}

/* Module Selection */
.module-selector {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.module-selector h2 {
    color: #ff6b4a;
    margin-bottom: 15px;
}

.module-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.module-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #555;
    border-radius: 5px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
}

.module-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #ff6b4a;
}

.module-btn.active {
    background: #61180f;
    border-color: #ff6b4a;
}

.module-btn.offline {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Module Details */
.module-details {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    display: none;
}

.module-details.active {
    display: block;
}

.module-details h2 {
    color: #ff6b4a;
    margin-bottom: 15px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.detail-card {
    background: rgba(255, 255, 255, 0.08);
    padding: 15px;
    border-radius: 8px;
}

.detail-card h3 {
    color: #ff6b4a;
    font-size: 1.1em;
    margin-bottom: 10px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.detail-row:last-child {
    border-bottom: none;
}

/* Cell Voltages Grid */
.cells-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.cell-card {
    background: rgba(255, 255, 255, 0.08);
    padding: 10px;
    border-radius: 5px;
    text-align: center;
}

.cell-number {
    font-size: 0.8em;
    color: #aaa;
}

.cell-voltage {
    font-size: 1.2em;
    font-weight: bold;
    color: #4CAF50;
}

/* Terminal Section */
.terminal-section {
    margin-top: 20px;
}

.terminal-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 10px 10px 0 0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s;
}

.terminal-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.terminal-header h2 {
    color: #ff6b4a;
    margin: 0;
}

.terminal-toggle {
    font-size: 1.5em;
    transition: transform 0.3s;
}

.terminal-toggle.collapsed {
    transform: rotate(-90deg);
}

.terminal-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0 0 10px 10px;
    padding: 15px;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.terminal-container.collapsed {
    max-height: 0;
    padding: 0 15px;
}

.terminal {
    background: #1e1e1e;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    padding: 15px;
    border-radius: 8px;
    height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.terminal-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.terminal-button {
    padding: 8px 16px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.terminal-button:hover {
    background: #45a049;
}

/* Inverter Settings Section */
.settings-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border: 2px solid #61180f;
}

.settings-section h2 {
    color: #ff6b4a;
    margin-bottom: 15px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.settings-card {
    background: rgba(255, 255, 255, 0.08);
    padding: 15px;
    border-radius: 8px;
}

.settings-card h3 {
    color: #ff6b4a;
    font-size: 1.1em;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    gap: 10px;
}

.setting-row label {
    color: #cccccc;
    min-width: 120px;
}

.setting-value {
    font-weight: bold;
    color: #4CAF50;
}

.settings-card select {
    flex: 1;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #555;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    min-width: 150px;
}

.btn-small {
    padding: 6px 12px;
    background: #61180f;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
}

.btn-small:hover {
    background: #7a1f13;
}

.btn-write {
    width: 100%;
    padding: 12px 20px;
    background: #4CAF50;
    font-size: 1.1em;
}

.btn-write:hover {
    background: #45a049;
}

.settings-status {
    margin-top: 10px;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
}

.settings-status.success {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}

.settings-status.error {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

.settings-status.loading {
    background: rgba(255, 152, 0, 0.2);
    color: #ff9800;
}

/* Write Register Section */
.write-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.write-section h2 {
    color: #ff6b4a;
    margin-bottom: 15px;
}

.write-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 5px;
    color: #cccccc;
}

.form-group input, .form-group select {
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #555;
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn {
    padding: 10px 20px;
    background: #61180f;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.btn:hover:not(:disabled) {
    background: #7a1f13;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .stat-value {
        font-size: 1.5em;
    }
}

