/*
 * PhyNet dashboard layout.
 * The design remains readable on smartphones, classroom projectors and desktops.
 */

:root {
    --background: #f3f6f3;
    --surface: #ffffff;
    --surface-soft: #f8faf8;
    --text: #18211b;
    --muted: #5b675e;
    --line: #dce4dd;
    --primary: #23623a;
    --primary-dark: #17472a;
    --danger: #a52828;
    --danger-dark: #7f1d1d;
    --shadow: 0 10px 30px rgba(24, 33, 27, 0.07);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

html {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--background);
}

body {
    margin: 0;
    min-width: 320px;
    line-height: 1.5;
}

button,
input,
select {
    font: inherit;
}

.site-header {
    padding: 3.5rem max(1.25rem, calc((100vw - 1440px) / 2));
    color: #ffffff;
    background: linear-gradient(130deg, #163c25, #2f7648);
}

.site-header > div {
    max-width: 900px;
}

.eyebrow,
.section-number {
    margin: 0 0 0.35rem;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.site-header h1 {
    max-width: 820px;
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.75rem);
    line-height: 1.05;
}

.lead {
    max-width: 760px;
    margin: 1rem 0 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 1.08rem;
}

.page-shell {
    width: min(1440px, calc(100% - 2rem));
    margin: -1.5rem auto 4rem;
}

.panel,
.summary-card,
.chart-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel {
    padding: clamp(1rem, 2.4vw, 1.75rem);
    margin-bottom: 1.25rem;
}

.panel-heading,
.device-selection-header,
.chart-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.panel-heading {
    margin-bottom: 1.25rem;
}

.panel-heading h2,
.chart-heading h3 {
    margin: 0;
}

.section-number {
    color: var(--primary);
}

.dataset-grid,
.two-column-section,
.admin-grid,
.summary-grid {
    display: grid;
    gap: 1rem;
}

.dataset-grid,
.two-column-section {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dataset-card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
    min-width: 0;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}

.dataset-card legend {
    padding: 0 0.4rem;
    font-weight: 800;
    color: var(--primary-dark);
}

.filter-grid,
.admin-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.filter-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

label {
    display: grid;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 650;
}

input,
select {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.65rem 0.75rem;
    color: var(--text);
    border: 1px solid #cbd6cc;
    border-radius: 9px;
    background: #ffffff;
}

input:focus,
select:focus,
button:focus-visible {
    outline: 3px solid rgba(35, 98, 58, 0.2);
    outline-offset: 2px;
    border-color: var(--primary);
}

.inline-options,
.button-row,
.device-checkboxes {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.inline-options {
    margin-top: 1rem;
}

.checkbox-label,
.device-checkbox {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
}

.checkbox-label input,
.device-checkbox input {
    width: 1.05rem;
    min-height: 1.05rem;
    margin: 0;
}

.device-checkbox {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    background: var(--surface-soft);
}

.device-checkbox:has(input:checked) {
    border-color: #8bb59a;
    background: #eaf5ed;
}

.button-row {
    margin-top: 1rem;
}

.compact-buttons {
    margin-top: 0;
}

.button {
    min-height: 2.7rem;
    padding: 0.62rem 0.95rem;
    border: 1px solid transparent;
    border-radius: 9px;
    font-weight: 750;
    cursor: pointer;
}

.button:disabled {
    opacity: 0.55;
    cursor: wait;
}

.button.primary {
    color: #ffffff;
    background: var(--primary);
}

.button.primary:hover {
    background: var(--primary-dark);
}

.button.secondary {
    color: var(--text);
    border-color: var(--line);
    background: #ffffff;
}

.button.secondary:hover {
    background: var(--surface-soft);
}

.button.danger {
    color: #ffffff;
    background: var(--danger);
}

.button.danger:hover {
    background: var(--danger-dark);
}

.status-message {
    min-height: 1.5rem;
    margin: 1rem 0 0;
    color: var(--muted);
}

.status-message.success {
    color: #1c6a36;
}

.status-message.warning {
    color: #8a5b00;
}

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

.summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 1.25rem;
}

.summary-card {
    display: grid;
    gap: 0.25rem;
    padding: 1.1rem 1.25rem;
}

.summary-card span {
    color: var(--muted);
    font-size: 0.85rem;
}

.summary-card strong {
    overflow-wrap: anywhere;
    font-size: clamp(1.25rem, 2vw, 1.8rem);
}

.panel-note {
    max-width: 1000px;
    margin: -0.4rem 0 1rem;
    color: var(--muted);
    font-size: 0.93rem;
}

.traffic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
    gap: 0.8rem;
}

.traffic-card {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.9rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}

.traffic-card > div {
    display: grid;
    gap: 0.1rem;
}

.traffic-card span {
    color: var(--muted);
    font-size: 0.84rem;
}

.traffic-light {
    flex: 0 0 auto;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
}

.traffic-card.green .traffic-light {
    background: #22a447;
}

.traffic-card.yellow .traffic-light {
    background: #e4ae12;
}

.traffic-card.red .traffic-light {
    background: #d93636;
}

.charts-container {
    display: grid;
    gap: 1rem;
}

.chart-card {
    min-width: 0;
    padding: 1rem;
    box-shadow: none;
}

.chart-heading span {
    color: var(--muted);
    font-weight: 700;
}

.plot {
    width: 100%;
    min-width: 0;
}

.plot-large {
    min-height: 430px;
}

.plot-medium {
    min-height: 390px;
}

.empty-message {
    margin: 0;
    padding: 2rem;
    color: var(--muted);
    text-align: center;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 11px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

th {
    color: #34423a;
    background: var(--surface-soft);
}

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

.compact-table {
    margin-top: 0.75rem;
}

.standalone-label {
    max-width: 420px;
    margin-bottom: 1rem;
}

.admin-panel {
    border-color: #c8d5ca;
}

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.5rem max(1.25rem, calc((100vw - 1440px) / 2));
    color: #d6e1d8;
    background: #17241b;
}

.site-footer p {
    margin: 0;
}

.site-footer a {
    color: #ffffff;
}

[hidden] {
    display: none !important;
}

@media (max-width: 1050px) {
    .dataset-grid,
    .two-column-section,
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-grid,
    .admin-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .site-header {
        padding-top: 2.5rem;
        padding-bottom: 3.5rem;
    }

    .page-shell {
        width: min(100% - 1rem, 1440px);
    }

    .dataset-grid,
    .two-column-section,
    .summary-grid,
    .filter-grid,
    .admin-grid,
    .dataset-card {
        grid-template-columns: 1fr;
    }

    .panel,
    .chart-card {
        border-radius: 12px;
    }

    .plot-large,
    .plot-medium {
        min-height: 360px;
    }

    .button-row .button {
        flex: 1 1 auto;
    }
}
