body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f6f9;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-size: 16px;
}

header {
    background-color: #343a40; /* Darker shade */
    color: white;
    padding: 1rem 1.5rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    margin: 0;
    font-weight: 500;
    font-size: 1.8rem;
}

header h1 .material-icons {
    font-size: 2rem; /* Adjust icon size */
    margin-right: 8px;
}

main {
    flex-grow: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem; /* Space between sections */
}

#controls, #widgets {
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

#controls h2, #widgets h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.75rem;
    font-weight: 500;
    font-size: 1.5rem;
    color: #495057;
}

#controls h2 .material-icons,
#widgets h2 .material-icons {
    vertical-align: bottom;
    margin-right: 8px;
    font-size: 1.6rem;
}

.control-group {
    margin-bottom: 1rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #495057;
}

.control-group select,
.control-group button {
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border: 1px solid #ced4da;
    font-size: 1rem;
}

.control-group button {
    background-color: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.control-group button:hover {
    background-color: #0056b3;
}

.control-group button .material-icons {
    vertical-align: middle;
    margin-right: 4px;
    font-size: 1.2rem;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 0.75rem 1.25rem;
    border-radius: 0.25rem;
    margin-top: 1rem;
}

.widget-container {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.widget-container h3 {
    margin-top: 0;
    font-weight: 500;
    font-size: 1.25rem;
    color: #343a40;
    border-bottom: 1px solid #f1f3f5;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}
.widget-container h3 .material-icons {
    vertical-align: bottom;
    margin-right: 6px;
    font-size: 1.4rem;
}

/* Table Styles */
.table-responsive {
    overflow-x: auto; /* For responsive tables on small screens */
}

#data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

#data-table th, #data-table td {
    border: 1px solid #dee2e6;
    padding: 0.75rem;
    text-align: left;
    vertical-align: top;
}

#data-table th {
    background-color: #e9ecef;
    font-weight: 500;
    color: #495057;
}

#data-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}
#data-table tbody tr:hover {
    background-color: #e9ecef;
}


/* Chart Styles */
.chart-controls {
    margin-bottom: 1rem;
}
.chart-controls label {
    margin-right: 0.5rem;
}
.chart-canvas-container {
    position: relative;
    min-height: 300px; /* Minimum height */
    max-height: 450px; /* Maximum height */
    width: 100%;
}
#data-chart {
    /* Chart.js will handle its own sizing within the container */
}


/* Card Styles */
.cards-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Responsive grid */
    gap: 1rem;
    margin-top: 10px;
}

.data-card {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-left: 5px solid #007bff; /* Accent border */
    border-radius: 5px;
    padding: 1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.data-card.red-accent { border-left-color: #dc3545; }
.data-card.green-accent { border-left-color: #28a745; }
.data-card.yellow-accent { border-left-color: #ffc107; }
.data-card.purple-accent { border-left-color: #6f42c1; }


.data-card h4 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: #495057;
    display: flex;
    align-items: center;
}
.data-card h4 .material-icons {
    margin-right: 8px;
    font-size: 1.2rem;
    color: #6c757d;
}

.data-card p.card-value {
    margin-bottom: 0;
    font-size: 1.75rem;
    font-weight: bold;
    color: #343a40;
}
.data-card p.card-description {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 0.25rem;
}


footer {
    background-color: #343a40;
    color: white;
    text-align: center;
    padding: 1rem;
    margin-top: auto; /* Pushes footer to the bottom */
    font-size: 0.9rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    main {
        padding: 1rem;
    }
    header h1 {
        font-size: 1.5rem;
    }
    #controls h2, #widgets h2 {
        font-size: 1.3rem;
    }
    .widget-container h3 {
        font-size: 1.1rem;
    }
    .cards-layout {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    .data-card p.card-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.3rem;
    }
    .control-group select,
    .control-group button {
        width: 100%; /* Full width for controls on small screens */
        margin-top: 0.5rem;
    }
    .control-group button:first-of-type {
        margin-top: 0;
    }
    .cards-layout {
        grid-template-columns: 1fr; /* Single column for cards */
    }
}

/* Utility classes */
.hidden {
    display: none !important;
}
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}
.loader {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
