:root {
    --bg: #f4f5f9;
    --card: #ffffff;
    --ink: #161a29;
    --muted: #6b7280;
    --line: #e6e8ef;
    --brand: #d51f2b;
    --brand-dark: #a5151f;
    --brand-soft: #fdeaea;
    --sidebar: #12141f;
    --sidebar-soft: #1c1f2e;
    --ok: #0f9d58;
    --warn: #d97706;
    --danger: #dc2626;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

/* hidden 属性必须能压过 .stack / .row 这类 display 规则，否则收起无效 */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Pretendard", "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 236px;
    flex: 0 0 236px;
    background: var(--sidebar);
    color: #cfd2e1;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, #f0392c, #6b0b10);
    display: grid; place-items: center;
    font-weight: 800; color: #fff; font-size: 13px; letter-spacing: .5px;
}
.brand-name { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.brand-sub { color: #7d839c; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; }

.nav-group { margin-top: 14px; }
.nav-title {
    font-size: 13.5px; font-weight: 700; letter-spacing: .06em;
    color: #9aa2c0; padding: 0 10px; margin-bottom: 8px;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 9px;
    color: #b9bdd1; font-size: 13.5px; margin-bottom: 2px;
    transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-soft); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-item.disabled { color: #5c627a; cursor: default; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }
.nav-sub { padding-left: 36px; font-size: 13px; margin-bottom: 1px; position: relative; }
.nav-sub .ico { width: 14px; font-size: 11px; opacity: .7; }
.nav-sub::before { content: ''; position: absolute; left: 21px; top: 7px; bottom: 7px; width: 1px; background: rgba(255,255,255,.12); }
.nav-badge {
    margin-left: auto; font-size: 10px; padding: 1px 6px;
    border-radius: 999px; background: rgba(255,255,255,.08); color: #8e94ad;
}
.sidebar-foot { margin-top: auto; color: #5c627a; font-size: 11px; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.06); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 64px; background: #fff; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; letter-spacing: .2px; }
.topbar .crumb { color: var(--muted); font-size: 12px; }

.user-menu { display: flex; align-items: center; gap: 12px; }
.lang-select {
    height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line);
    background: #fff; color: #4b5563; font-size: 12.5px; cursor: pointer;
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-chip .role { font-size: 11px; color: var(--muted); }

.content { padding: 26px 28px 48px; width: 100%; }

/* ---------- Cards ---------- */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head {
    padding: 18px 22px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.card-body { padding: 22px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- Stats ---------- */
.stat { padding: 20px 22px; }
.stat .label { color: var(--muted); font-size: 12px; letter-spacing: .02em; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.stat .hint { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.stat .accent { color: var(--brand); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
    font-size: 13px; font-weight: 600; cursor: pointer; line-height: 1.2;
    transition: background .15s, border-color .15s, color .15s;
    font-family: inherit; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--line); color: #374151; }
.btn-ghost:hover { border-color: #c9cddb; color: var(--ink); }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.label { font-size: 12.5px; font-weight: 600; color: #374151; }
.label .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #d8dbe6; border-radius: 9px;
    background: #fff; font-size: 13.5px; color: var(--ink); font-family: inherit;
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--brand); box-shadow: 0 0 0 3px rgba(213, 31, 43, .12);
}
.input::placeholder { color: #a2a8b8; }
.hint { font-size: 11.5px; color: var(--muted); }
.error { font-size: 12px; color: var(--danger); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; }

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted); font-weight: 600; padding: 12px 18px; border-bottom: 1px solid var(--line);
    background: #fafbfd; white-space: nowrap;
}
.table td { padding: 14px 18px; border-bottom: 1px solid #f0f2f7; vertical-align: middle; }
.table tbody tr:hover { background: #fbfcfe; }
.table tbody tr:last-child td { border-bottom: 0; }

.person { display: flex; align-items: center; gap: 11px; }
.person .name { font-weight: 600; font-size: 13.5px; }
.person .sub { font-size: 11.5px; color: var(--muted); }

.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
    display: grid; place-items: center; font-size: 13px; font-weight: 700;
    background: var(--brand-soft); color: var(--brand);
}
.avatar.lg { width: 60px; height: 60px; flex-basis: 60px; font-size: 22px; border-radius: 18px; }

/* ---------- 项目 LOGO ---------- */
/* 不固定尺寸：按原图比例显示，长边最多 40px（详情页 56px），小图不放大 */
.project-logo {
    max-width: 40px; max-height: 40px; width: auto; height: auto;
    flex: 0 0 auto; border-radius: 9px;
    border: 1px solid var(--line); background: #fff;
    display: block; overflow: hidden;
}
.project-logo-lg { max-width: 56px; max-height: 56px; border-radius: 13px; }

/* 没有 LOGO 时的首字母色块，本身要有确定大小，才能撑住标题前的占位 */
.project-logo-fallback {
    width: 40px; height: 40px; min-width: 40px; display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 16px;
}
.project-logo-lg.project-logo-fallback {
    width: 56px; height: 56px; min-width: 56px; border-radius: 13px; font-size: 22px;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
    background: #f1f3f8; color: #4b5563; white-space: nowrap;
}
.badge.green { background: #e9f8f0; color: #087f4b; }
.badge.gray { background: #f1f3f8; color: #6b7280; }
.badge.red { background: #fef2f2; color: #b91c1c; }
.badge.purple { background: #161a29; color: #fff; }
.badge.amber { background: #fff7ed; color: #b45309; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 18px;
    border: 1px solid transparent; display: flex; gap: 10px; align-items: flex-start;
}
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert strong { font-weight: 700; }

/* ---------- Misc ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; padding: 8px 11px; font-size: 13px; }
.divider { height: 1px; background: var(--line); margin: 20px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
/* 行内操作按钮（编辑 / 删除等）：form 用 flex 包裹，避免 inline 行盒把按钮顶高，和相邻链接错位 */
.row > form { display: flex; align-items: center; gap: 6px; margin: 0; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }

.kv { display: grid; grid-template-columns: 100px 1fr; gap: 10px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.pagination { display: flex; gap: 6px; align-items: center; padding: 14px 18px; border-top: 1px solid var(--line); }
.pagination a, .pagination span {
    min-width: 30px; height: 30px; border-radius: 8px; display: inline-flex;
    align-items: center; justify-content: center; font-size: 12.5px;
    border: 1px solid var(--line); color: #4b5563; background: #fff; padding: 0 9px;
}
.pagination .current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pagination .disabled { color: #c3c8d4; }
.pagination .info { border: 0; color: var(--muted); margin-left: auto; }

.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 6px; }

/* ---------- Auth ---------- */
.auth-body {
    min-height: 100vh; display: grid; place-items: center; padding: 32px 18px;
    background:
        radial-gradient(900px 500px at 12% -10%, #ffe0da 0%, transparent 60%),
        radial-gradient(700px 480px at 100% 0%, #f6dcdc 0%, transparent 55%),
        #f4f5f9;
}
.auth-wrap { width: 100%; max-width: 430px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 18px; }
.auth-brand .brand-mark { width: 38px; height: 38px; font-size: 14px; }
.auth-brand .t1 { font-weight: 800; letter-spacing: .4px; }
.auth-brand .t2 { font-size: 11px; color: var(--muted); letter-spacing: .16em; text-transform: uppercase; }
.auth-card { background: #fff; border-radius: 18px; border: 1px solid #e6e8f0; box-shadow: 0 24px 60px rgba(23, 25, 45, .12); padding: 30px 30px 26px; }
.auth-card h1 { font-size: 19px; margin: 0 0 6px; letter-spacing: -.01em; }
.auth-card .lead { color: var(--muted); font-size: 12.8px; margin: 0 0 22px; }
.auth-card .btn { width: 100%; padding: 11px 16px; margin-top: 6px; }
.auth-foot { text-align: center; color: #8b90a3; font-size: 11.5px; margin-top: 18px; }
.auth-steps { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.auth-steps .step { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.auth-steps .step .n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; background: #eef0f6; color: #8b90a3; }
.auth-steps .step.done .n { background: #e9f8f0; color: #087f4b; }
.auth-steps .step.current .n { background: var(--brand); color: #fff; }
.auth-steps .step.current { color: var(--ink); font-weight: 600; }
.auth-steps .bar { flex: 1; height: 1px; background: var(--line); }

.otp-input {
    width: 100%; text-align: center; font-size: 26px; letter-spacing: .5em;
    font-weight: 700; padding: 13px 10px 13px 20px; border-radius: 11px;
    border: 1px solid #d8dbe6; font-family: "SFMono-Regular", Consolas, monospace;
}
.otp-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }

.qr-box { display: grid; place-items: center; padding: 14px; background: #fff; border: 1px dashed #cfd3e3; border-radius: 14px; width: fit-content; margin: 0 auto; }
.qr-box svg { display: block; width: 210px; height: 210px; }
.secret {
    font-family: Consolas, monospace; font-size: 12.5px; letter-spacing: .12em;
    background: #f6f7fb; border: 1px solid var(--line); padding: 9px 12px;
    border-radius: 9px; text-align: center; word-break: break-all; color: #374151;
}
.steps-list { margin: 0; padding-left: 18px; color: #4b5563; font-size: 12.8px; }
.steps-list li { margin-bottom: 5px; }

/* ---------- AI placeholder ---------- */
.ai-card { padding: 20px; display: flex; gap: 14px; align-items: flex-start; opacity: .92; }
.ai-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: var(--brand-soft); }
.ai-card h3 { margin: 0 0 3px; font-size: 14px; }
.ai-card p { margin: 0; font-size: 12.3px; color: var(--muted); }

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: relative; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 14px; gap: 6px; overflow: visible; }
    .brand { padding: 0 8px 0 0; }
    .sidebar-foot { display: none; }
    .nav-group { display: flex; gap: 4px; margin: 0; }
    .nav-title { display: none; }
    .nav-item { padding: 7px 10px; }
    .content { padding: 18px 16px 40px; }
    .topbar { padding: 0 16px; }
    .form-grid, .grid-2, .grid-4 { grid-template-columns: 1fr; }
}
/* 工作台：考勤 / 模块速览 */
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-3 .card { display: flex; flex-direction: column; }
.grid-3 .card-body { padding: 18px; }
.att-time-row { display: flex; align-items: flex-end; gap: 24px; margin-bottom: 12px; }
.att-time { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.punch-list { display: flex; flex-direction: column; gap: 6px; max-height: 128px; overflow-y: auto; }
.punch-row { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; }
.punch-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13.5px; color: var(--ink); }
.progress { height: 6px; border-radius: 999px; background: #eef0f6; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.link-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; color: inherit; }
.link-row:hover { border-color: #c9cddb; background: #fbfcfe; }
.link-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); font-size: 14px; flex: 0 0 auto; }
.link-title { display: block; font-size: 13.5px; font-weight: 600; }
.link-desc { display: block; font-size: 11.5px; color: var(--muted); }
@media (max-width: 1024px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .grid-3 { grid-template-columns: 1fr; } }
/* 项目中心：页签与标签 */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { padding: 9px 14px; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); font-size: 12px; line-height: 1.6; }
.tag-x { border: 0; background: transparent; color: var(--brand-dark); cursor: pointer; font-size: 13px; line-height: 1; padding: 0; opacity: .55; }
.tag-x:hover { opacity: 1; }
/* 项目时线：日历 */
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { text-align: center; padding: 10px 6px; font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
.cal td { vertical-align: top; height: 112px; padding: 6px; border-bottom: 1px solid #f0f2f7; border-right: 1px solid #f0f2f7; }
.cal td:last-child { border-right: 0; }
.cal td.other { background: #fafbfd; }
.cal td.today { box-shadow: inset 0 0 0 2px var(--brand); }
.cal-day { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.cal-num { font-size: 12px; font-weight: 600; color: #374151; }
.cal td.other .cal-num { color: #c3c8d4; }
.cal-add { color: #c3c8d4; text-decoration: none; line-height: 1; font-size: 15px; padding: 0 2px; }
.cal-add:hover { color: var(--brand); }
.cal-event { display: block; font-size: 11.5px; line-height: 1.35; padding: 3px 6px; margin-bottom: 3px; border-radius: 6px; background: #f5f6fa; color: #374151; border-left: 3px solid #cbd0da; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event:hover { background: #eef0f7; color: #161a29; }
.cal-time { font-weight: 600; font-variant-numeric: tabular-nums; margin-right: 3px; color: #6b7280; }
.cal-more { font-size: 11px; color: var(--muted); padding-left: 2px; }
.cal-legend { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: #f5f6fa; border-left: 3px solid #cbd0da; }
.tone-purple { border-left-color: #161a29; }
.tone-green { border-left-color: #087f4b; }
.tone-amber { border-left-color: #b45309; }
.tone-red { border-left-color: #b91c1c; }
.tone-gray { border-left-color: #9ca3af; }
/* 项目时线：AI 月度报告 */
.report-body { white-space: pre-wrap; line-height: 1.85; font-size: 13.5px; color: #374151; background: #fbfcfe; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
/* 项目时线：年表（横向年份轴 + 月份卡片） */
.year-axis { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.year-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: #374151; font-size: 12.5px; font-weight: 600; }
.year-chip span { font-weight: 400; font-size: 11px; color: var(--muted); }
.year-chip:hover { border-color: #c9cddb; color: var(--ink); }
.year-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.year-chip.active span { color: rgba(255, 255, 255, .78); }
.month-card.is-empty { opacity: .55; }
.year-event { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f3f4f8; color: #374151; font-size: 12.5px; }
.year-event:last-of-type { border-bottom: 0; }
.year-event .d { min-width: 38px; color: var(--muted); font-variant-numeric: tabular-nums; }
.year-event .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.year-event:hover .t { color: var(--brand); }
.year-event .badge { flex: 0 0 auto; }
