* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #e0f7fa, #e8f5e9); /* 蓝色 -> 绿色渐变 */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 800px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

header h1 {
    font-size: 26px;
    color: #1a5e47;
}

header #uid {
    color: #4682b4;
    font-weight: bold;
    margin-left: 15px;
}

#refresh-btn {
    background: #4db6ac;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

#refresh-btn:hover {
    background: #26a69a;
}

/* 统计卡片 */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.stat-label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 22px;
    font-weight: bold;
    color: #2e7d32;
}

/* 记录列表 */
.records {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.records h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
}

#log-list {
    list-style: none;
}

.log-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 15px;
    gap: 10px; /* 间隙，防止换行时贴在一起 */
}

.log-item:last-child {
    border-bottom: none;
}

.log-item .time {
    color: #555;
    white-space: nowrap; /* 防止时间换行 */
}

.log-item .ip {
    color: #777;
    flex: 1; /* 让 IP 自动填充中间空间 */
    text-align: center;
    min-width: 0;
}

.log-item .reason {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    flex-shrink: 0; /* 防止标签被压缩 */
}

.reason-login {
    background: #4caf50; /* 绿色 */
}

.reason-logout {
    background: #2196f3; /* 蓝色 */
}

.empty,
.error {
    text-align: center;
    padding: 20px;
    color: #999;
}

.error {
    color: #e57373;
}

/* ===================== 手机端适配 ===================== */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 16px;
        border-radius: 14px;
    }

    header {
        flex-wrap: wrap; /* 允许换行 */
        gap: 10px 15px;  /* 行间距和列间距 */
        margin-bottom: 15px;
        padding-bottom: 15px;
    }

    header h1 {
        font-size: 22px;
    }

    header #uid {
        margin-left: 0; /* 取消左侧边距 */
        font-size: 14px;
        flex: 1;      /* 占据剩余空间 */
    }

    #refresh-btn {
        width: 100%;       /* 按钮占满一行 */
        padding: 10px;
        font-size: 16px;
        border-radius: 10px;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr); /* 两列 */
        gap: 10px;
        margin-bottom: 15px;
    }

    .stat-card {
        padding: 10px;
    }

    .stat-value {
        font-size: 18px;
    }

    .records {
        padding: 14px;
    }

    .records h2 {
        font-size: 16px;
    }

    .log-item {
        flex-wrap: wrap;      /* 允许内部换行 */
        row-gap: 6px;         /* 换行后的垂直间距 */
        font-size: 14px;
        padding: 10px 0;
    }

    /* 时间占满一行，IP 占余下空间，reason 靠右 */
    .log-item .time {
        flex: 1 1 100%;       /* 独占一行 */
        white-space: normal;  /* 允许换行，但时间通常很短 */
    }

    .log-item .ip {
        flex: 1 1 auto;       /* 占据剩余宽度 */
        text-align: left;
        font-size: 13px;
        word-break: break-all; /* 防止 IP 过长溢出 */
    }

    .log-item .reason {
        margin-left: auto;    /* 靠右 */
        font-size: 11px;
        padding: 3px 10px;
    }
}

/* 手机小屏优化（如 360px 以下） */
@media (max-width: 380px) {
    .container {
        padding: 12px;
    }

    header h1 {
        font-size: 20px;
    }

    .stat-card {
        padding: 8px;
    }

    .stat-value {
        font-size: 16px;
    }
}
