/* Dashboard page */

.dash-view {
    display: flex;
    flex-direction: column;
    gap: var(--s5);
    min-width: 0;
}

/* Live status line above the readings */
.dash-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s2) var(--s4);
    margin-bottom: calc(-1 * var(--s2));
}

.dash-status-text {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s1) var(--s2);
    color: var(--ink-dim);
    font-size: var(--text-sm);
}

.dash-status-text .faint {
    font-size: var(--text-xs);
}

#last-update {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.dash-status-controls {
    display: flex;
    align-items: center;
    gap: var(--s3);
}

.dash-check {
    display: flex;
    align-items: center;
    gap: var(--s2);
    color: var(--ink-dim);
    font-size: var(--text-sm);
    cursor: pointer;
}

/* Reading tiles */
.dash-tile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s2);
    min-height: 20px;
}

.dash-readings .readout-value {
    font-variant-numeric: proportional-nums;
}

.dash-pair {
    display: grid;
    gap: var(--s1);
    margin: 0;
}

.dash-pair > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s3);
}

.dash-pair dt {
    color: var(--ink-faint);
    font-size: var(--text-2xs);
}

.dash-pair dd {
    margin: 0;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: var(--text-md);
    line-height: 1.25;
    white-space: nowrap;
}

/* Bandwidth + recent activity */
.dash-columns {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: var(--s5);
    align-items: start;
}

.dash-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2) var(--s5);
    margin-bottom: var(--s3);
}

.dash-legend-item {
    display: flex;
    align-items: center;
    gap: var(--s2);
}

.dash-legend-value {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

/* Legend key mirrors the mark: a short 2px line */
.dash-key {
    display: inline-block;
    width: 16px;
    height: 2px;
    border-radius: 1px;
}

.dash-key--ch1 { background: var(--ch1); }
.dash-key--ch2 { background: var(--ch2); }

.dash-chart-card {
    padding: var(--s3) var(--s3) var(--s1);
}

.dash-chart {
    position: relative;
    width: 100%;
    min-height: 206px;
}

.dash-chart svg {
    display: block;
    width: 100%;
    overflow: visible;
    touch-action: pan-y;
}

.dash-chart .grid { stroke: var(--graticule); stroke-width: 1; shape-rendering: crispEdges; }
.dash-chart .axis-text { fill: var(--ink-dim); font-family: var(--font-mono); font-size: 10px; font-variant-numeric: tabular-nums; }
.dash-chart .dash-chart-empty { fill: var(--ink-dim); font-family: var(--font-body); font-size: 12px; }
.dash-chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dash-chart .line--recv { stroke: var(--ch1); }
.dash-chart .line--sent { stroke: var(--ch2); }
.dash-chart .dot { stroke: var(--screen); stroke-width: 2; }
.dash-chart .dot--recv { fill: var(--ch1); }
.dash-chart .dot--sent { fill: var(--ch2); }
.dash-chart .crosshair { stroke: var(--ink-faint); stroke-width: 1; shape-rendering: crispEdges; }

.dash-tooltip {
    display: none;
}

.dash-tooltip .tt-time {
    display: block;
    margin-bottom: 2px;
    color: var(--ink-dim);
    font-family: var(--font-mono);
}

.dash-tooltip .tt-row {
    display: block;
}

.dash-tooltip strong {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 600;
}

.dash-tooltip .tt-key {
    display: inline-block;
    width: 10px;
    height: 2px;
    margin-right: var(--s2);
    vertical-align: middle;
}

.dash-tooltip .tt-key--recv { background: var(--ch1); }
.dash-tooltip .tt-key--sent { background: var(--ch2); }

.dash-foot {
    margin-top: var(--s2);
    color: var(--ink-faint);
    font-size: var(--text-2xs);
    text-align: right;
}

/* Recent file activity */
.dash-activity {
    max-height: 330px;
    overflow: auto;
}

.dash-activity-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.dash-act {
    display: flex;
    align-items: center;
    gap: var(--s3);
    min-height: 36px;
    padding: var(--s1) var(--s3);
    border-top: 1px solid var(--graticule);
    font-size: var(--text-sm);
}

.dash-act:first-child {
    border-top: 0;
}

.dash-act-time {
    flex: none;
    min-width: 6ch;
    white-space: nowrap;
    color: var(--ink-faint);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
}

.dash-act .tag {
    flex: none;
}

.dash-act-file {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Log views */
.dash-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--s3);
    margin-bottom: var(--s4);
}

.dash-filter {
    flex: 0 1 220px;
    min-width: 160px;
}

.dash-table-box {
    max-height: min(68vh, 720px);
}

.dash-table-box--short {
    max-height: 244px;
}

.dash-table-box.is-loading .table {
    opacity: 0.55;
    transition: opacity var(--dur) var(--ease);
}

.dash-log-table td {
    font-size: var(--text-xs);
}

.dash-log-table .dash-cell-time {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--ink-dim);
}

.dash-log-table .dash-cell-path {
    min-width: 220px;
    max-width: 480px;
    font-family: var(--font-mono);
    overflow-wrap: anywhere;
}

.dash-log-table .dash-cell-ua {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-faint);
}

.dash-log-table td.mono {
    white-space: nowrap;
}

.dash-pager {
    display: flex;
    justify-content: center;
    margin-top: var(--s3);
}

.dash-pager:has(> [hidden]:only-child) {
    display: none;
}

@media (max-width: 1100px) {
    .dash-columns {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 600px) {
    .page-actions {
        width: 100%;
    }

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

    .dash-status-controls {
        width: 100%;
        justify-content: space-between;
    }

    .dash-filter {
        flex: 1 1 100%;
    }

    .dash-filters .key {
        flex: 1 1 auto;
    }
}

@media (max-width: 420px) {
    .dash-readings .reading {
        padding: var(--s3);
    }
}
