* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    background: #f4f6f9;
    color: #1f2430;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 20px 64px;
}

.header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 24px;
}

.header h1 {
    font-size: 1.4rem;
    margin: 0;
}

.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.08);
    padding: 24px;
    margin-bottom: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: #2f6feb;
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn:hover {
    background: #2559c2;
}

.btn.secondary {
    background: #fff;
    color: #384152;
    border-color: #d8dee6;
}

.btn.secondary:hover {
    background: #f2f4f7;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    align-items: flex-end;
}

.filters label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    color: #667085;
}

.filters input {
    padding: 6px 10px;
    border: 1px solid #d8dee6;
    border-radius: 6px;
    font-size: 0.9rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #eef0f3;
    vertical-align: top;
}

th {
    color: #667085;
    font-weight: 600;
    background: #fafbfc;
}

.programs-cell {
    max-width: 320px;
    word-break: break-all;
    color: #384152;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    font-size: 0.85rem;
    color: #667085;
}

.login-panel {
    text-align: center;
    padding: 40px 0;
}

.qr-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-modal[hidden] {
    display: none;
}

.qr-box {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    width: 280px;
    text-align: center;
}

.qr-box img {
    width: 200px;
    height: 200px;
    margin: 12px 0;
}

.qr-box .close {
    background: none;
    border: none;
    float: right;
    font-size: 1rem;
    cursor: pointer;
    color: #667085;
}

.hint {
    color: #667085;
    font-size: 0.85rem;
}

.error-text {
    color: #d92d20;
    font-size: 0.85rem;
    margin-top: 8px;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: #667085;
}

.empty-state {
    text-align: center;
    padding: 40px 0;
    color: #98a2b3;
}

/* 选项卡（列表 / 开机时间分布 / 使用时长） */
.tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #eef0f3;
    margin-bottom: 16px;
}

.tab-btn {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #667085;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    top: 1px;
}

.tab-btn:hover {
    color: #384152;
}

.tab-btn.active {
    color: #2f6feb;
    border-bottom-color: #2f6feb;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* 开机时间分布 / 使用时长 统计区块 */
.stat-section {
    padding: 20px;
    background: #fafbfc;
    border: 1px solid #eef0f3;
    border-radius: 10px;
    margin-bottom: 20px;
    position: relative;
}

.stat-section:last-child {
    margin-bottom: 0;
}

.stat-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #384152;
    margin-bottom: 12px;
}

.stat-canvas-wrap {
    position: relative;
    overflow-x: auto;
}

.stat-chart-wrap {
    position: relative;
    height: 260px;
}

.stat-chart-wrap canvas {
    width: 100%;
    height: 100%;
}

.chart-tooltip {
    position: absolute;
    background: #1f2430;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 1000;
    display: none;
    max-width: 260px;
}

.chart-tooltip.show {
    display: block;
}

.chart-tooltip .tooltip-title {
    font-weight: 700;
    margin-bottom: 4px;
}

.chart-tooltip .tooltip-line {
    margin: 2px 0;
    line-height: 1.4;
}

/* 应用使用时长：按日期 + 24 小时格 */
.appusage-toolbar {
    margin-bottom: 16px;
}

.app-hourly-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.app-hourly-row {
    display: grid;
    grid-template-columns: 28px 120px 1fr 72px;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.app-hourly-header {
    color: #98a2b3;
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.app-hourly-rank {
    color: #98a2b3;
    text-align: right;
    font-weight: 600;
}

.app-hourly-name {
    color: #384152;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-hourly-cells {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 2px;
    min-width: 0;
}

.app-hourly-scale {
    position: relative;
    height: 14px;
}

.app-hourly-scale span {
    position: absolute;
    transform: translateX(-50%);
    font-size: 0.7rem;
}

.app-hourly-scale span:nth-child(1) { left: 0; }
.app-hourly-scale span:nth-child(2) { left: 25%; }
.app-hourly-scale span:nth-child(3) { left: 50%; }
.app-hourly-scale span:nth-child(4) { left: 75%; }
.app-hourly-scale span:nth-child(5) { left: 100%; }

.app-hourly-cell {
    aspect-ratio: 1;
    min-height: 14px;
    border-radius: 3px;
    border: 1px solid #e2e8f0;
    background: #f1f5f9;
    cursor: default;
}

.app-hourly-total {
    color: #667085;
    text-align: right;
    white-space: nowrap;
    font-size: 0.8rem;
}

.app-hourly-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #eef0f3;
    font-size: 0.75rem;
    color: #64748b;
}

.app-hourly-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.app-hourly-legend-item i {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid #cbd5e1;
    font-style: normal;
}

@media (max-width: 768px) {
    .app-hourly-row {
        grid-template-columns: 24px 80px 1fr 56px;
        font-size: 0.78rem;
    }
    .app-hourly-cell {
        min-height: 10px;
    }
}
