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

body {
    font-family: 'Inter', sans-serif;
    background: #f9fafb;
    color: #2d3748;
    line-height: 1.6;
    overflow-x: hidden;
}

/* App Wrapper */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #ffffff;
    color: #2d3748;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    border-right: 1px solid #e5e7eb;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 22px;
    font-weight: 700;
    color: #2d3748;
}

.logo i {
    font-size: 28px;
    color: #7c3aed;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.nav-section {
    margin-bottom: 32px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6b7280;
    padding: 0 20px;
    margin-bottom: 12px;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-weight: 500;
    font-size: 14px;
}

.nav-item:hover {
    background: #f9fafb;
    color: #2d3748;
}

.nav-item.active {
    background: #f3f4f6;
    color: #7c3aed;
    border-left-color: #7c3aed;
    font-weight: 600;
}

.nav-item i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
}

.logout-btn {
    width: 100%;
    justify-content: flex-start;
    border: none;
    color: #dc2626;
}

.logout-btn:hover {
    background: #fee2e2;
    color: #dc2626;
    border-left-color: #dc2626;
}

.settings-btn {
    background: transparent;
    border: none;
    color: #4b5563;
    border-left: 3px solid transparent;
}

.settings-btn:hover {
    background: #f3f4f6;
    color: #7c3aed;
    border-left-color: #7c3aed;
}

/* Content Area */
.content-area {
    flex: 1;
    margin-left: 280px;
    min-height: 100vh;
    background: #f9fafb;
    padding: 32px;
}

/* Main Content */
.main-content {
    width: 100%;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: none;
}

/* Top Header */
.top-header {
    background: #ffffff;
    padding: 28px 32px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    flex: 1;
}

.page-title {
    font-size: 32px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 8px 0;
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 15px;
    color: #6b7280;
    margin: 0;
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.date-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f5f7fa;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
}

.date-display i {
    color: #7c3aed;
}

.device-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 14px;
    color: #6b7280;
    background: #f5f7fa;
    padding: 8px 16px;
    border-radius: 12px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.connected {
    background-color: #16a34a;
}

.status-indicator.disconnected {
    background-color: #dc2626;
}

/* Tab Content */
.tab-content-wrapper {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
    display: block;
}

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

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #ffffff;
    padding: 32px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
}

.stat-card:hover {
    border-color: #d1d5db;
}

.stat-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 12px;
    color: #7c3aed;
    font-size: 28px;
    flex-shrink: 0;
}

.stat-icon-green {
    background: #f0fdf4;
    color: #16a34a;
}

.stat-icon-yellow {
    background: #fffbeb;
    color: #d97706;
}

.stat-icon-red {
    background: #fef2f2;
    color: #dc2626;
}

.stat-info h3 {
    font-size: 32px;
    color: #2d3748;
    margin-bottom: 6px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.stat-info p {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
    font-weight: 500;
}

/* Panels */
.panel {
    background: #ffffff;
    padding: 32px;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid #e5e7eb;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.panel-title i {
    font-size: 22px;
    color: #7c3aed;
}

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

.panel-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.panel h2 {
    color: #2d3748;
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.3px;
}

.panel h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #2d3748;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
    background: #f5f7fa;
    border: 2px dashed #d1d5db;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
}

.quick-action-btn:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #7c3aed;
    color: #7c3aed;
}

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

.quick-action-btn i {
    font-size: 32px;
}

.quick-action-btn span {
    font-weight: 600;
    font-size: 14px;
}

/* Connection Form */
.connection-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.connection-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.connection-actions .btn {
    flex: 1;
    justify-content: center;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group i {
    position: absolute;
    left: 14px;
    color: #94a3b8;
    font-size: 16px;
    z-index: 1;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 12px 14px 12px 42px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.2s;
    background: #ffffff;
    color: #1e293b;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #7c3aed;
}

.device-actions {
    display: flex;
    flex-direction: row;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.device-actions .btn {
    flex: 1;
    min-width: 200px;
    justify-content: center;
    padding: 14px 20px;
    font-weight: 500;
}

.device-actions .btn-primary {
    background: #ede9fe;
    color: #7c3aed;
    border-color: #ddd6fe;
}

.device-actions .btn-primary:hover:not(:disabled) {
    background: #ddd6fe;
    color: #6d28d9;
    border-color: #c4b5fd;
}

.device-actions .btn-success {
    background: #dcfce7;
    color: #16a34a;
    border-color: #bbf7d0;
}

.device-actions .btn-success:hover:not(:disabled) {
    background: #bbf7d0;
    color: #15803d;
    border-color: #86efac;
}

.device-actions .btn-info {
    background: #dbeafe;
    color: #2563eb;
    border-color: #bfdbfe;
}

.device-actions .btn-info:hover:not(:disabled) {
    background: #bfdbfe;
    color: #1d4ed8;
    border-color: #93c5fd;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    line-height: 1.5;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: #7c3aed;
    color: white;
    border-color: #7c3aed;
}

.btn-primary:hover:not(:disabled) {
    background: #6d28d9;
    border-color: #6d28d9;
}

.btn-secondary {
    background: #ffffff;
    color: #4b5563;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #2d3748;
}

.btn-success {
    background: #16a34a;
    color: white;
    border-color: #16a34a;
}

.btn-success:hover:not(:disabled) {
    background: #15803d;
    border-color: #15803d;
}

.btn-info {
    background: #0891b2;
    color: white;
    border-color: #0891b2;
}

.btn-info:hover:not(:disabled) {
    background: #0e7490;
    border-color: #0e7490;
}

.btn-danger {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
    border-color: #b91c1c;
}

/* Filter Controls */
.filter-section {
    margin-bottom: 20px;
    padding: 24px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.filter-form {
    width: 100%;
}

.filter-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.filter-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filter-column:last-child {
    justify-content: flex-start;
    padding-top: 28px;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-field label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 4px;
}

.time-period-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.datetime-input-group {
    display: flex;
    gap: 6px;
    flex: 1;
}

.time-separator {
    color: #6b7280;
    font-weight: 500;
    padding: 0 4px;
}

.date-input,
.time-input,
.text-input,
.select-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: #ffffff;
    color: #1f2937;
    transition: all 0.2s;
    font-family: inherit;
}

.date-input {
    flex: 1;
    min-width: 140px;
}

.time-input {
    width: 100px;
}

.text-input {
    width: 100%;
}

.date-input:focus,
.time-input:focus,
.text-input:focus,
.select-input:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.filter-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-actions .btn {
    width: 100%;
    justify-content: center;
}

@media (max-width: 1200px) {
    .filter-columns {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filter-column:last-child {
        grid-column: 1 / -1;
        flex-direction: row;
        padding-top: 0;
    }
    
    .filter-actions {
        flex-direction: row;
    }
    
    .filter-actions .btn {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .filter-columns {
        grid-template-columns: 1fr;
    }
    
    .filter-column:last-child {
        grid-column: 1;
    }
}

/* Tables */
.table-container {
    overflow-x: auto;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    max-height: 600px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #f5f7fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 16px 20px;
    text-align: left;
    font-weight: 600;
    color: #4b5563;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #d1d5db;
}

td {
    padding: 16px 20px;
    border-bottom: 1px solid #eef2f6;
    font-size: 14px;
    color: #2d3748;
}

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover {
    background: #f5f7fa;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Report Tables */
.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 24px;
}

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

.report-table-section {
    margin-bottom: 20px;
}

.report-table-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: #0f172a;
    font-size: 18px;
    font-weight: 600;
}

.report-table-section h3 i {
    color: #7c3aed;
}

/* Messages */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    font-size: 14px;
}

.text-danger {
    color: #dc2626;
    font-weight: 600;
}

/* Toast Messages */
.toast-message {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    font-size: 14px;
    font-weight: 500;
    min-width: 300px;
    max-width: 500px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-message.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-message[data-type="success"] {
    background: #f0fdf4;
    color: #166534;
    border-left: 4px solid #16a34a;
}

.toast-message[data-type="error"] {
    background: #fef2f2;
    color: #991b1b;
    border-left: 4px solid #dc2626;
}

.toast-message[data-type="info"] {
    background: #eff6ff;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.toast-message[data-type="warning"] {
    background: #fffbeb;
    color: #92400e;
    border-left: 4px solid #f59e0b;
    border-left: 4px solid #3b82f6;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.toast-content i {
    font-size: 18px;
}

.toast-close {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.toast-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
}

.modal-header h2 i {
    color: #7c3aed;
}

.modal-close {
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 18px;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #2d3748;
}

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.form-group label i {
    color: #7c3aed;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    background: #ffffff;
    color: #1e293b;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.form-actions .btn {
    min-width: 120px;
    justify-content: center;
}

/* Responsive */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content-area {
        margin-left: 0;
    }

    .report-tables {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .tab-content-wrapper {
        padding: 16px;
    }

    .top-header {
        padding: 16px 20px;
    }

    .panel {
        padding: 20px;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .filter-row {
        flex-direction: column;
    }

    .connection-actions {
        flex-direction: column;
    }

    .device-actions {
        flex-direction: column;
    }
}