:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1f2937;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-info: #3b82f6;
    --border-color: #2d3748;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.section {
    margin-bottom: 25px;
}

.section h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-success);
}

.status-dot.online {
    background: var(--accent-success);
    box-shadow: 0 0 5px var(--accent-success);
}

.drag-source {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drag-item {
    background: var(--bg-tertiary);
    padding: 10px 12px;
    border-radius: 6px;
    cursor: move;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    border: 1px solid transparent;
}

.drag-item:hover {
    background: #2d3748;
    border-color: var(--accent-info);
    transform: translateX(3px);
}

.drag-item i {
    width: 20px;
    color: var(--accent-info);
}

.btn-primary, .btn-secondary, .btn-icon {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
    margin-bottom: 8px;
    width: 100%;
}

.btn-primary {
    background: var(--accent-info);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #2d3748;
}

.btn-icon {
    width: auto;
    padding: 8px 12px;
    background: var(--bg-tertiary);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    background: var(--bg-secondary);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar h1 {
    font-size: 1.25rem;
}

.top-bar-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#lastUpdate {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.grid-stack {
    flex: 1;
    padding: 20px;
    background: var(--bg-primary);
    overflow-y: auto;
}

.grid-stack-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.grid-stack-item-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.widget-header {
    padding: 12px 15px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

.widget-title {
    font-weight: 600;
    font-size: 0.875rem;
}

.widget-actions {
    display: flex;
    gap: 8px;
}

.widget-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.widget-actions button:hover {
    color: var(--accent-danger);
}

.widget-body {
    flex: 1;
    padding: 15px;
    overflow: auto;
}

.widget-card {
    text-align: center;
    padding: 20px;
}

.widget-card .card-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 10px 0;
}

.widget-card .card-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.widget-table table {
    width: 100%;
    font-size: 0.75rem;
    border-collapse: collapse;
}

.widget-table th, .widget-table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.widget-chart canvas {
    max-height: 200px;
}

.status-success { color: var(--accent-success); }
.status-warning { color: var(--accent-warning); }
.status-danger { color: var(--accent-danger); }

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: 8px;
    width: 400px;
}

.modal-content input {
    width: 100%;
    padding: 10px;
    margin: 15px 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
}

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

.modal-buttons button {
    flex: 1;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        height: 100vh;
        z-index: 100;
    }
    
    .sidebar.open {
        left: 0;
    }
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4a5568;
}

.loading, .error {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.error {
    color: var(--accent-danger);
}

.refresh-control {
    margin-top: 10px;
}

.refresh-control label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.refresh-control select {
    width: 100%;
    padding: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
}
