/* ===========================================================
   Rayden 100天改变计划 - 样式文件
   字体: Inter + PingFang SC
   主题色: #5b5bd6 (紫色)
   =========================================================== */

/* === Google Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* === CSS 变量 === */
:root {
    --bg: #f4f7fb;
    --surface: #fff;
    --surface2: #f8fafc;
    --text: #162033;
    --muted: #687386;
    --line: #e4e9f1;
    --primary: #5b5bd6;
    --primary2: #7777ea;
    --primary-dark: #4f4fc4;
    --success: #1f9d72;
    --warning: #d58a19;
    --danger: #d04f5f;
    --shadow: 0 10px 30px rgba(31, 42, 68, .08);
    --shadow-sm: 0 2px 8px rgba(31, 42, 68, .04);
    --shadow-md: 0 4px 16px rgba(31, 42, 68, .06);
    --radius: 16px;
    --radius-sm: 10px;
    --ring: 0deg;
    /* 字体栈 */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
}

/* === 暗色模式 === */
[data-theme="dark"] {
    --bg: #0f1420;
    --surface: #171e2c;
    --surface2: #111827;
    --text: #edf2f7;
    --muted: #9aa6b8;
    --line: #293246;
    --primary: #8a8aff;
    --primary2: #a1a1ff;
    --primary-dark: #6e6efa;
    --success: #48c89b;
    --warning: #f0ad4e;
    --danger: #ff7584;
    --shadow: 0 12px 35px rgba(0, 0, 0, .25);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .15);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .2);
}

/* === 全局重置 === */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === 应用容器 === */
.app {
    max-width: 1280px;
    margin: auto;
    padding: 24px;
}

/* === 顶部栏 === */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.brand h1 {
    font-family: var(--font);
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 4px;
    letter-spacing: -0.5px;
}

.brand p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
}

.top-actions {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* === 按钮系统 === */
.btn,
.icon-btn {
    border: 1px solid #d1d5db;
    /* zinc-300 边框 */
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 9px 15px;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
    /* 细微阴影 */
    transition: all 0.2s ease;
    line-height: 1.4;
}

.btn:hover,
.icon-btn:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active,
.icon-btn:active {
    transform: translateY(0);
}

/* 主按钮 - 明显阴影和 hover 效果 */
.btn.primary {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(91, 91, 214, .35);
    font-weight: 700;
}

.btn.primary:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    box-shadow: 0 6px 20px rgba(91, 91, 214, .45);
    transform: translateY(-2px);
}

.btn.danger {
    color: var(--danger);
    border-color: var(--danger);
}

.btn.danger:hover {
    background: var(--danger);
    color: #fff;
}

.icon-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* === Hero 区域 === */
.hero {
    background: linear-gradient(125deg, var(--primary-dark), var(--primary2));
    color: #fff;
    border-radius: 20px;
    padding: 28px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 1.6fr .8fr;
    gap: 20px;
    margin-bottom: 18px;
}

.hero h2 {
    font-size: 32px;
    font-weight: 800;
    margin: 0 0 7px;
    letter-spacing: -0.5px;
}

.hero p {
    margin: 0;
    opacity: .88;
    font-weight: 400;
}

.hero-status {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
}

.countdown {
    font-size: 13px;
    opacity: .85;
    text-align: right;
}

.countdown strong {
    display: block;
    font-size: 32px;
    line-height: 1.1;
    color: #fff;
    font-weight: 800;
}

/* 圆形进度环 */
.ring {
    width: 116px;
    height: 116px;
    border-radius: 50%;
    background: conic-gradient(#fff var(--ring), rgba(255, 255, 255, .2) 0);
    display: grid;
    place-items: center;
    position: relative;
    flex-shrink: 0;
}

.ring::after {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background: #6868df;
}

.ring span {
    position: relative;
    z-index: 2;
    font-weight: 800;
    font-size: 22px;
}

/* === 标签导航 === */
.tabs {
    display: flex;
    gap: 8px;
    overflow: auto;
    padding: 4px 0 14px;
    position: sticky;
    top: 0;
    background: linear-gradient(var(--bg) 80%, transparent);
    z-index: 20;
}

.tab {
    white-space: nowrap;
    border: 1px solid #d1d5db;
    /* zinc-300 边框 */
    background: var(--surface);
    color: var(--muted);
    border-radius: 22px;
    padding: 8px 20px;
    font-family: var(--font);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(91, 91, 214, .3);
}

.tab:hover:not(.active) {
    border-color: var(--primary);
    color: var(--primary);
}

/* === 视图切换 === */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* === 网格布局 === */
.grid {
    display: grid;
    gap: 16px;
}

.grid.kpis {
    grid-template-columns: repeat(5, 1fr);
    margin-bottom: 16px;
}

.today-layout {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.week-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

/* === 卡片 === */
.card {
    background: var(--surface);
    border: 1px solid #d1d5db;
    /* zinc-300 边框 */
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    /* 细微阴影区分层级 */
}

.week-card {
    box-shadow: var(--shadow-md);
}

.week-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

/* KPI 卡片 */
.kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 800;
    margin: 2px 0;
    letter-spacing: -0.5px;
}

.kpi-sub {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

/* 进度条 */
.progress {
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    overflow: hidden;
}

.progress i {
    display: block;
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* === 区域标题 === */
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.section-title h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.day-badge {
    font-size: 11px;
    font-weight: 600;
    background: var(--surface2);
    color: var(--muted);
    border: 1px solid #d1d5db;
    padding: 3px 10px;
    border-radius: 12px;
}

.small {
    font-size: 12px;
    color: var(--muted);
}

/* === 日期导航 === */
.date-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-nav input[type="date"] {
    border: 1px solid #d1d5db;
    /* zinc-300 边框 */
    background: var(--surface);
    color: var(--text);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    transition: border-color 0.2s;
}

.date-nav input[type="date"]:focus {
    border-color: var(--primary);
    outline: none;
}

/* === 任务列表 === */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid #d1d5db;
    /* zinc-300 边框 */
    border-radius: var(--radius-sm);
    background: var(--surface2);
    cursor: pointer;
    transition: all 0.2s;
}

.task:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.task.done {
    opacity: 0.75;
    background: var(--surface);
}

.task.done .task-title {
    text-decoration: line-through;
    color: var(--muted);
}

.task input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.pill {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    margin-right: 8px;
    text-transform: uppercase;
}

.task-title {
    font-weight: 600;
    font-size: 15px;
}

.task-desc {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
    white-space: pre-line;
}

/* === 时间轴 === */
.timeline {
    font-size: 14px;
    white-space: pre-line;
    line-height: 1.7;
    color: var(--muted);
}

/* === 表单 === */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* 标签和输入框垂直间距一致 */
}

.field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.field input,
.field textarea,
.field select {
    border: 1px solid #d1d5db;
    /* zinc-300 边框 - 清晰可见 */
    background: var(--surface);
    color: var(--text);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 400;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    border-color: #4f46e5;
    /* indigo-600 focus */
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.field textarea {
    min-height: 70px;
    resize: vertical;
    line-height: 1.5;
}

.field input[type="number"] {
    text-align: right;
    /* 数字右对齐 */
    font-variant-numeric: tabular-nums;
    /* 等宽数字 */
}

.field select {
    cursor: pointer;
}

/* === 表格 === */
.table-wrap {
    overflow-x: auto;
    margin-top: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
}

table th,
table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #d1d5db;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 列宽分配 */
table th:nth-child(1),
table td:nth-child(1) {
    width: 90px;
    white-space: nowrap;
}

table th:nth-child(2),
table td:nth-child(2) {
    width: 105px;
}

table th:nth-child(3),
table td:nth-child(3) {
    width: 28%;
}

table th:nth-child(4),
table td:nth-child(4) {
    width: 28%;
}

table th:nth-child(5),
table td:nth-child(5) {
    width: 12%;
}

table th:nth-child(6),
table td:nth-child(6) {
    width: 70px;
}

table th:nth-child(7),
table td:nth-child(7) {
    width: 55px;
}

table th {
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--muted);
    background: var(--surface2);
    position: sticky;
    top: 0;
}

/* 表格中数字右对齐，文本左对齐 */
table td.numeric,
table td:nth-child(7),
table td:nth-child(6) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

table tr:hover td {
    background: var(--surface2);
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-dot.complete {
    background: var(--success);
}

.status-dot.partial {
    background: var(--warning);
}

.status-dot.none {
    background: #d1d5db;
}

.day-link {
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.day-link:hover {
    color: var(--primary-dark);
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 24px !important;
    font-style: italic;
}

/* 内联输入 */
.inline-input {
    width: 80px;
    padding: 5px 8px;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s;
}

.inline-input:focus {
    border-color: var(--primary);
    outline: none;
}

/* === 筛选器 === */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.filters input,
.filters select {
    border: 1px solid #d1d5db;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
}

.filters input:focus,
.filters select:focus {
    border-color: var(--primary);
    outline: none;
}

/* === 详情卡片 === */
.detail-item {
    padding: 14px;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm);
    background: var(--surface2);
}

.detail-item h4 {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    margin: 0 0 6px;
    letter-spacing: 0.5px;
}

.detail-item p {
    margin: 0;
    font-size: 14px;
    white-space: pre-line;
    line-height: 1.6;
}

/* === 基金/财务 === */
.money-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.money-box {
    background: var(--surface2);
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.money-box span {
    display: block;
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.money-box b {
    display: block;
    font-size: 20px;
    font-weight: 800;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

/* === 周复盘 === */
.week-range {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
    font-weight: 500;
}

/* === 模态框 === */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.open {
    display: flex;
}

.modal-card {
    background: var(--surface);
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    padding: 24px;
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.close {
    border: none;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    color: var(--muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close:hover {
    background: var(--surface2);
    color: var(--text);
}

/* === Toast 提示 === */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: var(--bg);
    padding: 10px 24px;
    border-radius: 22px;
    font-weight: 600;
    font-size: 14px;
    font-family: var(--font);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 200;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* === 加载指示器 === */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--line);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    z-index: 300;
    opacity: 0;
    transition: opacity 0.2s;
}

.loading-overlay.active {
    opacity: 1;
    animation: loadingBar 1.5s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes loadingBar {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* === 页脚 === */
.footer {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    padding: 30px 0 16px;
}

/* === 保存状态指示 === */
.save-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--success);
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s;
}

.save-indicator.visible {
    opacity: 1;
}

.save-indicator.error {
    color: var(--danger);
}

.save-indicator.saving {
    color: var(--warning);
}

/* ==================== 响应式 ==================== */

/* 平板 */
@media(max-width:980px) {
    .grid.kpis {
        grid-template-columns: repeat(2, 1fr);
    }

    .today-layout,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .week-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero {
        grid-template-columns: 1fr;
    }

    .hero-status {
        justify-content: flex-start;
    }

    .countdown {
        text-align: left;
    }
}

/* 手机 */
@media(max-width:650px) {
    .app {
        padding: 14px 12px 82px;
    }

    .topbar {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .brand h1 {
        font-size: 22px;
    }

    .top-actions .btn {
        display: none;
    }

    .hero {
        padding: 21px;
    }

    .hero h2 {
        font-size: 25px;
    }

    .ring {
        width: 96px;
        height: 96px;
    }

    .ring::after {
        background: #6666dc;
    }

    .grid.kpis {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .card {
        padding: 15px;
    }

    .kpi-value {
        font-size: 21px;
    }

    .week-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    /* 桌面标签栏隐藏 */
    .tabs {
        display: none;
    }

    /* 移动端底部导航 */
    .mobile-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        height: 66px;
        background: var(--surface);
        border-top: 1px solid #d1d5db;
        /* zinc-300 边框 */
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        z-index: 30;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, .06);
    }

    .mobile-nav button {
        border: 0;
        background: transparent;
        color: var(--muted);
        font-size: 11px;
        font-weight: 700;
        font-family: var(--font);
        cursor: pointer;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        transition: color 0.2s;
    }

    .mobile-nav button.active {
        color: var(--primary);
    }

    .mobile-nav span {
        display: block;
        font-size: 19px;
        line-height: 1.2;
    }

    .hero-status {
        justify-content: space-between;
    }

    .money-summary {
        grid-template-columns: 1fr 1fr;
    }
}

/* 桌面端隐藏移动导航 */
@media(min-width:651px) {
    .mobile-nav {
        display: none;
    }
}

/* ==================== 辅助 ==================== */

/* 无障碍：键盘焦点 */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* 选择文本颜色 */
::selection {
    background: var(--primary);
    color: #fff;
}
