/* ===== 主题变量 ===== */
:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --primary-bg: #eff6ff;
    --bg: #f3f4f6;
    --card: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 25px rgba(30,64,175,.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ===== 顶部导航 ===== */
.navbar {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(30,64,175,.2);
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar .brand {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    display: flex; align-items: center; gap: 8px;
}
.navbar .brand::before {
    content: '◆'; color: #fff; opacity: .8;
}
.navbar .menu { display: flex; gap: 6px; align-items: center; }
.navbar .menu a {
    color: rgba(255,255,255,.9);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    transition: all .15s;
}
.navbar .menu a:hover { background: rgba(255,255,255,.15); color: #fff; }
.navbar .menu a.active { background: rgba(255,255,255,.2); }
.navbar .user {
    color: #fff; font-size: 13px;
    display: flex; align-items: center; gap: 8px;
}
.navbar .user img {
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.4);
    object-fit: cover;
}
.navbar .user a { color: rgba(255,255,255,.85); }
.navbar .user a:hover { color: #fff; }

/* 导航栏右侧用户区 */
.nav-user {
    margin-left: auto;
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background .15s;
}
.nav-user:hover { background: rgba(255,255,255,.15); }
.nav-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    border: 2px solid rgba(255,255,255,.4);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
    overflow: hidden;
}
.nav-user img {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.4);
    object-fit: cover;
}
.nav-username {
    font-size: 13px;
    color: rgba(255,255,255,.9);
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    min-width: 140px;
    overflow: hidden;
    z-index: 200;
    margin-top: 4px;
}
.nav-user.open .nav-dropdown { display: block; }
.nav-dropdown a {
    display: block;
    padding: 10px 16px;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
}
.nav-dropdown a:hover { background: var(--bg); color: var(--primary); }

.menu-toggle {
    display: none;
    background: none; border: none; color: #fff;
    font-size: 22px; cursor: pointer; padding: 4px 8px;
}

/* ===== 容器 ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
}
.page-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title small {
    color: var(--text-light);
    font-weight: 400;
    font-size: 13px;
    margin-left: 8px;
}

/* ===== 卡片 ===== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn:active { transform: scale(.97); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-success { background: var(--success); }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); }
.btn-warning:hover { background: #d97706; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-bg); }

/* ===== 表单 ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text);
}
.form-group label .req { color: var(--danger); }
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,64,175,.12);
}
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { cursor: pointer; }
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
}

/* ===== 表格 ===== */
.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}
.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.table th {
    background: var(--primary-bg);
    font-weight: 600;
    color: var(--primary-dark);
}
.table tr:hover td { background: #fafbfc; }

/* ===== Badge / 状态徽章 ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.6;
    color: #fff;
}
.badge-prio { color: #fff; }

/* ===== 任务列表项 ===== */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-item {
    background: #fff;
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
    transition: all .15s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}
.task-item:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
    color: inherit;
}
.task-item.priority-P0 { border-left-color: #ef4444; }
.task-item.priority-P1 { border-left-color: #f97316; }
.task-item.priority-P2 { border-left-color: #3b82f6; }
.task-item.priority-P3 { border-left-color: #6b7280; }
.task-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--text);
}
.task-desc {
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--text-light);
    align-items: center;
}
.task-meta .meta-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.task-meta img.thumb {
    width: 16px; height: 16px; border-radius: 50%; object-fit: cover;
}
.task-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.task-tag {
    background: var(--primary-bg);
    color: var(--primary);
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 11px;
}

/* ===== 筛选条 ===== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
    background: #fff;
    padding: 10px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.filter-bar select, .filter-bar input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}
.filter-bar .spacer { flex: 1; }

/* ===== 统计卡片 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-card .label {
    color: var(--text-light);
    font-size: 12px;
    margin-bottom: 6px;
}
.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}
.stat-card .value.success { color: var(--success); }
.stat-card .value.warning { color: var(--warning); }
.stat-card .value.danger { color: var(--danger); }

/* ===== 提示信息 ===== */
.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 13px;
}
.alert-success { background: #d1fae5; color: #065f46; border-left: 3px solid var(--success); }
.alert-error { background: #fee2e2; color: #991b1b; border-left: 3px solid var(--danger); }
.alert-info { background: var(--primary-bg); color: var(--primary-dark); border-left: 3px solid var(--primary); }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 3px solid var(--warning); }

/* ===== 登录页 ===== */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,.2);
    padding: 32px 28px;
    width: 100%;
    max-width: 380px;
}
.login-box h1 {
    text-align: center;
    font-size: 22px;
    margin: 0 0 4px;
    color: var(--primary-dark);
}
.login-box .sub {
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: 24px;
}
.login-box .form-group { margin-bottom: 16px; }

/* ===== 上传区 ===== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    color: var(--text-light);
    cursor: pointer;
    transition: all .15s;
    background: #fafbfc;
    display: block;
    position: relative;
}
.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
}
/* 彻底隐藏原生 file input（避免某些 WebView/扩展显示原生按钮） */
.upload-area input[type=file],
.upload-area + input[type=file],
input[type=file].hidden-file {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    pointer-events: none !important;
    z-index: -1 !important;
}
.upload-area .icon { font-size: 32px; margin-bottom: 6px; }
.preview-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg);
}
.preview-item img {
    width: 100%; height: 100%; object-fit: cover;
}
.preview-item .remove {
    position: absolute;
    top: 4px; right: 4px;
    width: 22px; height: 22px;
    background: rgba(0,0,0,.6);
    color: #fff;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.preview-item .progress {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5);
    color: #fff;
    font-size: 11px;
    padding: 2px 4px;
    text-align: center;
}
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}
.gallery a {
    display: block;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg);
}
.gallery img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform .2s;
}
.gallery a:hover img { transform: scale(1.05); }

/* ===== 评论 ===== */
.comment {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: none; }
.comment .avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary-bg);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}
.comment .avatar img { width: 100%; height: 100%; object-fit: cover; }
.comment .body { flex: 1; }
.comment .name { font-weight: 500; font-size: 13px; }
.comment .time { color: var(--text-light); font-size: 11px; margin-left: 6px; }
.comment .content { margin-top: 4px; font-size: 13px; white-space: pre-wrap; }

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
    .container { padding: 12px; }
    .navbar { padding: 0 12px; height: 50px; }
    .navbar .brand { font-size: 15px; }
    .navbar .menu {
        position: absolute;
        top: 50px; left: 0; right: 0;
        background: var(--primary-dark);
        flex-direction: column;
        align-items: stretch;
        padding: 8px;
        gap: 4px;
        display: none;
        box-shadow: 0 4px 12px rgba(0,0,0,.2);
    }
    .navbar .menu.open { display: flex; }
    .navbar .menu a { padding: 10px 12px; border-radius: 6px; }
    .menu-toggle { display: block; }
    .navbar .user .name-text { display: none; }
    .nav-user { display: none; }
    .page-title { font-size: 17px; }

    /* 表格转卡片式 */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    /* 表单按钮组 */
    .form-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    .form-actions .btn { width: 100%; }

    /* 移动端浮动创建按钮 */
    .fab {
        position: fixed;
        right: 16px;
        bottom: 16px;
        width: 56px; height: 56px;
        border-radius: 50%;
        background: var(--primary);
        color: #fff;
        border: none;
        font-size: 24px;
        box-shadow: 0 6px 16px rgba(30,64,175,.4);
        z-index: 99;
        cursor: pointer;
    }
}
@media (min-width: 769px) {
    .fab { display: none; }
}

/* ===== 工具类 ===== */
.text-muted { color: var(--text-light); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.between { justify-content: space-between; }
.center { justify-content: center; align-items: center; }
.hidden { display: none; }
.empty {
    text-align: center;
    color: var(--text-light);
    padding: 40px 20px;
}
/* ===== 标签页切换 ===== */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: #fff;
    padding: 6px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.tabs a {
    padding: 8px 16px;
    border-radius: 6px;
    color: var(--text-light);
    font-size: 13px;
    text-decoration: none;
    transition: all .15s;
}
.tabs a:hover { color: var(--primary); background: var(--primary-bg); }
.tabs a.active { background: var(--primary); color: #fff; font-weight: 500; }

/* ===== 操作列下拉 ===== */
.action-menu { position: relative; display: inline-block; }
.action-menu summary {
    list-style: none;
    cursor: pointer;
}
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu summary::after { content: '▼'; font-size: 8px; margin-left: 4px; }
.action-panel {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    width: 260px;
    margin-top: 4px;
}
.action-menu[open] .action-panel { display: block; }
.action-panel form { margin-bottom: 0; }
.action-panel hr {
    margin: 10px 0;
    border: none;
    border-top: 1px solid var(--border);
}

/* ===== 仪表盘双栏卡片 ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 16px;
}
@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

/* ===== 表格内操作单元格 ===== */
.td-action { white-space: nowrap; }