/* 统一盒模型，避免不同元素在宽高计算上出现额外偏差。 */
* {
    box-sizing: border-box;
}

/* 全站基础字体、背景和文字颜色都在这里统一定义。 */
body {
    margin: 0;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    background: #f5f7fa;
    color: #333;
}

/* 弹窗打开时冻结底层页面滚动和手势行为。 */
body.modal-open {
    overflow: hidden;
    touch-action: none;
}

/* 登录页整体采用带渐变的浅色背景，弱化空白感。 */
.login-page {
    min-height: 100vh;
    background: radial-gradient(circle at top, #dfeee5 0%, #f5f7fa 52%, #eef2f6 100%);
}

/* 登录页主容器只负责把卡片居中。 */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* 登录卡片是桌面和移动端共用的基础容器。 */
.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 20px;
    box-shadow: 0 22px 70px rgba(44, 62, 80, 0.12);
    padding: 36px;
}

/* 登录标题、页面标题和弹窗标题都统一沿用同一套字重基础。 */
.login-header h1,
.topbar h1,
.modal-header h2 {
    margin: 0;
    font-weight: 600;
}

/* 站点域名标识用于弱化但不隐藏来源信息。 */
.eyebrow {
    margin: 0 0 10px;
    color: #20a53a;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* 登录页说明文本和更新时间文本共享基础灰色字号。 */
.subtle,
.update-time {
    color: #666;
    margin: 10px 0 0;
    font-size: 14px;
}

/* 更新时间行需要容纳状态提示，所以改成弹性布局。 */
.update-time {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* 手动刷新状态提示默认隐藏，只有写入文本时才淡入显示。 */
.refresh-status {
    min-height: 18px;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.refresh-status:not(:empty) {
    opacity: 1;
}

/* 手动刷新状态按不同结果给出不同颜色反馈。 */
.refresh-status-pending {
    color: #0f766e;
}

.refresh-status-success {
    color: #15803d;
}

.refresh-status-error {
    color: #b42318;
}

/* 登录页说明文本与表单之间保留额外垂直留白。 */
.login-header .subtle {
    margin-bottom: 40px;
}

/* 表单字段统一采用垂直布局，便于登录页和弹窗共用。 */
.field {
    display: block;
    margin-bottom: 16px;
}

/* 字段标签的字号和与输入框的间距在这里统一收口。 */
.field span {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: #666;
}

/* 输入框的边框、圆角和内边距为全站统一基线。 */
.field input {
    width: 100%;
    border: 1px solid #d9dee7;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    background: #fff;
    outline: none;
}

/* 聚焦态统一给绿色描边，和品牌主色保持一致。 */
.field input:focus {
    border-color: #20a53a;
    box-shadow: 0 0 0 4px rgba(32, 165, 58, 0.1);
}

/* 三类按钮共用圆角、鼠标手势和轻微动效。 */
.primary-button,
.secondary-button,
.icon-button {
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* 主按钮用于登录和改密提交，始终保持醒目的绿色渐变。 */
.primary-button {
    width: 100%;
    background: linear-gradient(135deg, #18994b 0%, #22b85a 100%);
    color: #fff;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
}

/* 次按钮用于刷新、改密入口和退出，保持更克制的描边样式。 */
.secondary-button {
    background: #fff;
    color: #56606b;
    border: 1px solid #d9dee7;
    padding: 10px 16px;
    font-size: 14px;
}

/* 手动刷新时会临时禁用按钮，禁用态不能再出现悬浮抬升效果。 */
.secondary-button:disabled {
    cursor: default;
    opacity: 0.72;
    transform: none;
}

/* 普通悬浮态保留轻微上浮反馈。 */
.secondary-button:hover,
.primary-button:hover {
    transform: translateY(-1px);
}

/* 页面级错误提示统一采用浅红色警示样式。 */
.alert {
    border-radius: 10px;
    padding: 12px 14px;
    margin: 0 0 16px;
    font-size: 13px;
}

.alert-error {
    background: #fff2f0;
    color: #b42318;
    border: 1px solid #fecaca;
}

/* 页面根容器控制整体最大宽度和左右留白。 */
.page-shell {
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px 20px 40px;
}

/* 顶部标题区默认是左右分栏，移动端会在断点内改成纵向堆叠。 */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}

/* 顶部操作按钮区在桌面端允许自然换行，窄屏会单独做更细的布局策略。 */
.top-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.top-actions form {
    margin: 0;
    width: auto;
}

/* 统计页白色外壳负责承载卡片和图表区域。 */
.dashboard-shell {
    width: 100%;
    min-height: 520px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 16px 55px rgba(33, 43, 54, 0.08);
    overflow: hidden;
}

/* 内层内容区负责统一四周内边距。 */
.bt-w-con {
    padding: 22px 24px;
    background: #fff;
}

/* 统计卡区域采用网格布局，桌面端自适应多列，移动端在断点里强制三列。 */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid #e6ebf1;
    padding-bottom: 18px;
}

.stat-item {
    min-width: 0;
    padding: 10px 6px;
}

/* 统计卡标题前的绿色圆点承担轻微动态提示作用。 */
.stat-label {
    display: flex;
    align-items: center;
    color: #666;
    font-size: 12px;
    margin-bottom: 6px;
}

.stat-label .dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #20a53a;
    margin-right: 8px;
    box-shadow: 0 0 0 0 rgba(32, 165, 58, 0.4);
    animation: pulse 2s infinite;
}

/* 圆点呼吸动画用于弱化“实时数据”的静态感。 */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(32, 165, 58, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(32, 165, 58, 0); }
    100% { box-shadow: 0 0 0 0 rgba(32, 165, 58, 0); }
}

/* 统计值使用更大的字号，保证在卡片区首先被扫到。 */
.stat-value {
    font-size: 28px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

/* 昨日和前日对比信息刻意弱化，避免压过主数值。 */
.stat-comparison {
    font-size: 12px;
    color: #98a2b3;
    line-height: 1.7;
}

/* 图表区保留纯白背景，避免与外层卡片产生视觉割裂。 */
.chart-section {
    background: #fff;
}

/* 图表标题区负责在标题和指标切换按钮之间做左右分布。 */
.chart-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 16px;
}

.chart-section h2 {
    margin: 0;
    font-size: 16px;
}

/* 图表指标切换区在窄屏下允许横向滚动，保证所有按钮完整可见。 */
.chart-tabs {
    display: inline-flex;
    padding-left: 1px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chart-tabs::-webkit-scrollbar {
    display: none;
}

/* 指标按钮使用相邻边重叠方式，避免出现双线。 */
.chart-tab {
    flex: 0 0 auto;
    position: relative;
    padding: 0 16px;
    height: 30px;
    line-height: 28px;
    font-size: 12px;
    border: 1px solid #d7dde6;
    color: #667085;
    cursor: pointer;
    user-select: none;
    background: #fff;
    margin-left: -1px;
    z-index: 1;
}

.chart-tab:first-child {
    border-radius: 6px 0 0 6px;
    margin-left: -1px;
}

.chart-tab:last-child {
    border-radius: 0 6px 6px 0;
}

/* 激活态只使用稳定的内描边高亮，避免边框厚度异常。 */
.chart-tab.active {
    position: relative;
    z-index: 2;
    color: #20a53a;
    border-color: #20a53a;
    background: #edf8f0;
    box-shadow: inset 0 0 0 1px #20a53a;
}

.chart-container {
    height: 290px;
    width: 100%;
}

/* 弹窗默认隐藏，只有脚本显式切换类名时才显示。 */
.modal-hidden {
    display: none;
}

.modal-visible {
    display: block;
}

/* 遮罩层覆盖整个页面，用来冻结底层交互。 */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    z-index: 4;
}

/* 弹窗外层容器通过 clamp 连续缩放，避免移动端看起来过重。 */
.modal-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 420px);
    border-radius: clamp(14px, 3.5vw, 18px);
    background: #fff;
    box-shadow: 0 20px 80px rgba(15, 23, 42, 0.18);
    padding: clamp(18px, 4.5vw, 24px);
    z-index: 5;
}

/* 弹窗标题区需要同时容纳标题和关闭按钮。 */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: clamp(10px, 2.4vw, 16px);
    margin-bottom: clamp(12px, 3vw, 18px);
}

.modal-header h2 {
    font-size: clamp(16px, 4.6vw, 20px);
    line-height: 1.25;
}

/* 关闭按钮也参与移动端尺寸缩放，避免手机屏幕上显得笨重。 */
.icon-button {
    width: clamp(30px, 7.8vw, 34px);
    height: clamp(30px, 7.8vw, 34px);
    background: #f3f4f6;
    color: #4b5563;
    font-size: clamp(18px, 4.8vw, 22px);
}

/* 弹窗内部提交按钮和字段区之间只保留必要留白。 */
.password-form .primary-button {
    margin-top: clamp(6px, 1.8vw, 8px);
}

.mt10 {
    margin-top: 10px;
}

/* 平板和中小屏手机的第一层响应式收口。 */
@media (max-width: 900px) {
    .page-shell {
        padding: 20px 16px 32px;
    }

    .topbar,
    .chart-section-header {
        flex-direction: column;
    }

    .topbar,
    .chart-section-header,
    .top-actions {
        align-items: stretch;
    }

    .top-actions {
        width: 100%;
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .top-actions .secondary-button,
    .top-actions form,
    .top-actions form .secondary-button {
        width: 100%;
        min-width: 0;
    }

    .top-actions > .secondary-button,
    .top-actions > form {
        flex: 1 1 0;
        min-width: 0;
    }

    .dashboard-shell {
        min-height: 0;
    }

    .bt-w-con {
        padding: 18px 16px;
    }

    .stats-container {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px 8px;
        padding-bottom: 16px;
        margin-bottom: 16px;
    }

    .stat-item {
        padding: 6px 2px;
    }

    .stat-label {
        font-size: 11px;
        margin-bottom: 4px;
    }

    .stat-label .dot {
        width: 6px;
        height: 6px;
        margin-right: 6px;
    }

    .stat-value {
        font-size: clamp(18px, 4.9vw, 24px);
        margin-bottom: 6px;
        line-height: 1.15;
    }

    .stat-comparison {
        font-size: 11px;
        line-height: 1.45;
    }

    .chart-section-header {
        gap: 12px;
    }

    .chart-tabs {
        width: 100%;
        padding-bottom: 4px;
    }

    .chart-container {
        height: 260px;
    }

    .modal-card {
        width: min(86vw, 380px);
        padding: clamp(16px, 4.2vw, 20px);
    }
}

/* 普通手机宽度下进一步缩小字体、间距和弹窗内部元素尺寸。 */
@media (max-width: 560px) {
    .page-shell {
        padding: 16px 12px 28px;
    }

    .login-card,
    .dashboard-shell {
        border-radius: 16px;
    }

    .bt-w-con {
        padding: 16px 12px;
    }

    .secondary-button,
    .primary-button {
        padding: 10px 10px;
        font-size: 12px;
    }

    .topbar h1,
    .chart-section h2 {
        font-size: 18px;
    }

    .update-time {
        font-size: 13px;
        gap: 6px;
    }

    .stats-container {
        gap: 8px 6px;
    }

    .stat-value {
        font-size: clamp(16px, 5.2vw, 20px);
    }

    .stat-comparison {
        font-size: 10px;
    }

    .chart-tab {
        padding: 0 12px;
        font-size: 11px;
    }

    .chart-container {
        height: 230px;
    }

    .modal-card {
        width: min(84vw, 340px);
        padding: clamp(14px, 4vw, 18px);
    }

    .modal-header {
        gap: clamp(8px, 2vw, 12px);
        margin-bottom: clamp(10px, 2.8vw, 14px);
    }

    .modal-header h2 {
        font-size: clamp(15px, 4.4vw, 18px);
    }

    .icon-button {
        width: clamp(28px, 7vw, 32px);
        height: clamp(28px, 7vw, 32px);
        font-size: clamp(17px, 4.5vw, 20px);
    }

    .field {
        margin-bottom: clamp(12px, 3vw, 14px);
    }

    .field span {
        font-size: clamp(11px, 3.2vw, 12px);
        margin-bottom: clamp(6px, 1.8vw, 7px);
    }

    .field input {
        padding: clamp(10px, 2.8vw, 11px) clamp(10px, 3vw, 12px);
        font-size: clamp(12px, 3.4vw, 13px);
        border-radius: 9px;
    }

    .password-form .primary-button {
        margin-top: 6px;
        padding: 10px 12px;
        font-size: 12px;
    }
}

/* 极窄屏兜底断点，只在非常有限的屏宽下进一步压缩尺寸并允许顶部按钮换行。 */
@media (max-width: 380px) {
    .login-shell {
        padding: 16px;
    }

    .login-card {
        padding: 28px 20px;
    }

    .stats-container {
        gap: 6px 4px;
    }

    .stat-label {
        font-size: 10px;
    }

    .stat-value {
        font-size: clamp(14px, 5.5vw, 18px);
    }

    .stat-comparison {
        font-size: 9px;
        line-height: 1.4;
    }

    .chart-tab {
        padding: 0 10px;
    }

    .top-actions {
        flex-wrap: wrap;
    }

    .top-actions > .secondary-button,
    .top-actions > form {
        flex: 1 1 calc(50% - 4px);
    }

    .secondary-button {
        padding: 9px 8px;
        font-size: 11px;
    }

    .modal-card {
        width: min(80vw, 320px);
        padding: 12px 10px;
        border-radius: 12px;
    }

    .modal-header {
        gap: 8px;
        margin-bottom: 10px;
    }

    .modal-header h2 {
        font-size: clamp(14px, 4.8vw, 16px);
    }

    .icon-button {
        width: 28px;
        height: 28px;
        font-size: 18px;
    }

    .field {
        margin-bottom: 12px;
    }

    .field span {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .field input {
        padding: 9px 10px;
        font-size: 12px;
        border-radius: 8px;
    }

    .password-form .primary-button {
        margin-top: 6px;
        padding: 10px 12px;
        font-size: 12px;
    }
}
