* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f5f7fa;
    color: #1a1a2e;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.logo {
    padding: 24px;
    font-size: 24px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 32px;
}

.tenant-section {
    padding: 20px;
    flex: 1;
}

.tenant-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.5);
    margin-bottom: 12px;
}

.tenant-list {
    margin-bottom: 16px;
}

.tenant-item {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.05);
    border: none;
    color: white;
    text-align: left;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.tenant-item:hover {
    background: rgba(255,255,255,0.1);
}

.tenant-item.active {
    background: #0f3460;
    border-left: 3px solid #e94560;
}

.btn-add-tenant {
    width: 100%;
    padding: 10px;
    background: rgba(255,255,255,0.1);
    border: 1px dashed rgba(255,255,255,0.3);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-add-tenant:hover {
    background: rgba(255,255,255,0.2);
}

.connection-status {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
}

.status-indicator.online {
    background: #4ade80;
    box-shadow: 0 0 8px #4ade80;
}

.status-indicator.offline {
    background: #ef4444;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 24px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.header h1 {
    font-size: 28px;
    font-weight: 600;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab:hover {
    color: #1a1a2e;
}

.tab.active {
    color: #0f3460;
    border-bottom-color: #0f3460;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ESL Grid */
.esl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.esl-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}

.esl-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.esl-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.esl-select {
    margin-right: 6px;
}

.esl-code {
    font-family: monospace;
    font-size: 16px;
    font-weight: 600;
    color: #0f3460;
    flex: 1;
}

.esl-status {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.esl-status.online {
    background: #dcfce7;
    color: #166534;
}

.esl-status.offline {
    background: #fee2e2;
    color: #991b1b;
}

.esl-details {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 16px;
}

.esl-details p {
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
}

.esl-actions {
    display: flex;
    gap: 8px;
}

/* Cards */
.card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.command-panels {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #0f3460;
    box-shadow: 0 0 0 3px rgba(15,52,96,0.1);
}

.color-picker {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.color-picker label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.button-group {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: #0f3460;
    color: white;
}

.btn-primary:hover {
    background: #1a4a7a;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #e2e8f0;
    color: #1a1a2e;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-outline {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: #475569;
}

.btn-outline:hover {
    background: #f1f5f9;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Batch bar */
.batch-bar {
    margin: 12px 0 16px 0;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.batch-bar .btn {
    padding: 6px 14px;
    font-size: 12px;
}

.batch-bar #batchCount {
    font-size: 12px;
    color: #64748b;
    margin-left: auto;
}

/* Tasks Table */
.tasks-table-container {
    overflow-x: auto;
}

.tasks-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tasks-table th,
.tasks-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.tasks-table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 13px;
    color: #475569;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.status-badge.pending { background: #fef3c7; color: #92400e; }
.status-badge.success { background: #dcfce7; color: #166534; }
.status-badge.failed { background: #fee2e2; color: #991b1b; }

/* Image Gallery */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.image-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.2s;
}

.image-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.image-preview {
    width: 100%;
    height: 150px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-name {
    padding: 10px;
    font-size: 12px;
    text-align: center;
    color: #475569;
}

.image-upload {
    padding: 20px;
    background: white;
    border-radius: 12px;
    border: 2px dashed #cbd5e1;
    text-align: center;
}

.image-upload input {
    margin-bottom: 12px;
}

/* Template styles */
.template-header {
    margin-bottom: 20px;
}

.template-list {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 20px;
}

.template-card {
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 200px;
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}

.template-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.template-card .template-name {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.template-card .template-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* User management */
.user-section {
    margin-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 16px;
}

.user-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.5);
    margin-bottom: 12px;
}

#userList {
    max-height: 150px;
    overflow-y: auto;
}

#userList::-webkit-scrollbar {
    width: 4px;
}

#userList::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
}

#userList::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

/* Logout section */
.logout-section {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}

.btn-logout {
    width: 100%;
    padding: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #f87171;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.15);
    color: #ef4444;
}

/* Logs */
.log-container {
    background: #1a1a2e;
    color: #a8ff78;
    font-family: monospace;
    font-size: 13px;
    padding: 16px;
    border-radius: 12px;
    height: 400px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.log-entry {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.log-entry.mqtt { color: #60a5fa; }
.log-entry.error { color: #f87171; }
.log-entry.system { color: #a8ff78; }

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.search-box input {
    padding: 10px 16px;
    width: 260px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 28px;
    width: 90%;
    max-width: 480px;
}

.modal-content h2 {
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 80px;
    }
    .sidebar .logo-text,
    .sidebar .tenant-section h3,
    .sidebar .tenant-item {
        display: none;
    }
    .main-content {
        margin-left: 80px;
    }
    .command-panels {
        grid-template-columns: 1fr;
    }
}