/* ═══════════════════════════════════════════════════
   Excel 卡片浏览器 — 终极样式 (v2.0)
   特性：毛玻璃、微交互动效、暗色主题、响应式
   ═══════════════════════════════════════════════════ */

/* ─── 全局重置 ────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ─── 全局触控优化 ──────────────────────────── */
/* 消除移动端 300ms 延迟，改善触控响应 */
button, a, input, textarea, select,
.file-item, .sheet-tab, .btn-card-edit,
.btn-upload, .btn-sm, .btn-cancel, .btn-save,
.btn-menu-toggle, .mobile-bottom-btn,
.modal-overlay, .sidebar-overlay, .card-item {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* 主色系（渐变蓝紫） */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --primary-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

    /* 语义色 */
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* 中性色 */
    --bg: #f8fafc;
    --bg-alt: #f1f5f9;
    --card-bg: #ffffff;
    --card-bg-alt: #fafbfc;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* 阴影 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.18);

    /* 圆角 */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* 尺寸 */
    --header-height: 64px;
    --sidebar-width: 320px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* 动画 */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition: 0.25s var(--ease);
    --transition-slow: 0.4s var(--ease);
}

/* ─── 深色模式 ────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --bg-alt: #1e293b;
        --card-bg: #1e293b;
        --card-bg-alt: #334155;
        --text: #f1f5f9;
        --text-secondary: #94a3b8;
        --text-tertiary: #64748b;
        --border: #334155;
        --border-light: #1e293b;
        --primary-light: rgba(99, 102, 241, 0.12);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI',
        'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── 顶部导航 ────────────────────────────────── */
.app-header {
    height: var(--header-height);
    background: var(--primary-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.header-icon {
    font-size: 22px;
}

/* 汉堡菜单按钮 (移动端) */
.btn-menu-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    flex-shrink: 0;
}

.btn-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.btn-menu-toggle:active {
    transform: scale(0.92);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-count-badge {
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(4px);
    padding: 5px 14px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 10px;
    cursor: default;
}

.user-badge i { font-size: 18px; }

.header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}
.header-btn:hover { background: rgba(255, 255, 255, 0.25); }

/* 游客 "登录后编辑" 提示按钮 */
.btn-card-login-hint {
    color: var(--primary);
    text-decoration: none;
    border: 1px dashed var(--primary);
    background: var(--primary-light);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all var(--transition);
}
.btn-card-login-hint:hover {
    background: var(--primary);
    color: #fff;
    text-decoration: none;
}

/* 禁用的编辑按钮 */
.btn-card-edit[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* 权限提示标记 */
.card-readonly-tag {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #fef3c7;
    color: #92400e;
    margin-left: 6px;
    font-weight: 600;
}

/* ─── 主容器 ─────────────────────────────────── */
.app-container {
    display: flex;
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    position: relative;
}

/* ─── 侧边栏 ─────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 50;
    transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.btn-upload {
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-upload:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-upload:active {
    transform: scale(0.96);
}

/* 侧边栏遮罩 (移动端) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 49;
    opacity: 0;
    transition: opacity var(--transition);
    backdrop-filter: blur(2px);
    pointer-events: none; /* 默认不拦截触控 */
}

.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto; /* 激活时才拦截 */
}

/* ─── 文件列表 ──────────────────────────────── */
.file-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
}

.file-list::-webkit-scrollbar {
    width: 4px;
}

.file-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    opacity: 0.2;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 14px;
    line-height: 1.6;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 4px;
    border: 1.5px solid transparent;
    position: relative;
    overflow: hidden;
}

.file-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--primary-gradient);
    transform: scaleY(0);
    transition: transform var(--transition);
}

.file-item:hover {
    background: var(--primary-light);
    border-color: var(--border);
}

.file-item.active {
    background: var(--primary-light);
    border-color: var(--primary);
}

.file-item.active::before {
    transform: scaleY(1);
}

.file-item .file-icon {
    font-size: 22px;
    color: var(--primary);
    margin-right: 14px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.file-item .file-info {
    flex: 1;
    min-width: 0;
}

.file-item .file-name {
    font-size: 14px;
    font-weight: 600;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item .file-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 3px;
}

.file-item .file-sheets {
    font-size: 11px;
    color: var(--primary);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── 主内容区 ──────────────────────────────── */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    position: relative;
    background: var(--bg);
}

.main-content::-webkit-scrollbar {
    width: 6px;
}

.main-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ─── 欢迎屏 ──────────────────────────────────── */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    color: var(--text-secondary);
    text-align: center;
    padding: 40px 20px;
}

.welcome-icon-wrapper {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.welcome-icon {
    font-size: 52px;
    color: var(--primary);
}

.welcome-screen h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.welcome-screen p {
    font-size: 14px;
    max-width: 280px;
    line-height: 1.6;
}

/* ─── 文件详情 ──────────────────────────────── */
.file-detail {
    animation: fadeSlideUp 0.35s var(--ease);
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
    border: 1px solid var(--border);
    gap: 12px;
}

.file-info-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.file-info-left i {
    color: var(--primary);
    font-size: 20px;
    flex-shrink: 0;
}

.file-info-left .file-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-info-right {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-sm {
    padding: 7px 14px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all var(--transition);
    color: var(--text-secondary);
}

.btn-sm:hover {
    background: var(--bg-alt);
    color: var(--text);
    transform: translateY(-1px);
}

.btn-sm:active {
    transform: scale(0.96);
}

.btn-refresh:hover {
    border-color: var(--info);
    color: var(--info);
}

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

/* ─── Sheet 标签 ────────────────────────────── */
.sheet-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

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

.sheet-tab {
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card-bg);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.sheet-tab:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.sheet-tab:active {
    transform: scale(0.95);
}

.sheet-tab.active {
    background: var(--primary-gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.sheet-tab .tab-badge {
    background: var(--border);
    padding: 1px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.sheet-tab.active .tab-badge {
    background: rgba(255, 255, 255, 0.25);
}

/* ─── 搜索筛选栏 ──────────────────────────── */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition);
}

.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-icon {
    color: var(--text-tertiary);
    font-size: 16px;
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    font-family: inherit;
    min-width: 0;
}

.search-bar input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

.search-clear {
    background: var(--bg-alt);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 12px;
    transition: all var(--transition);
    flex-shrink: 0;
    opacity: 0;
    pointer-events: none;
}

.search-clear.visible {
    opacity: 1;
    pointer-events: auto;
}

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

.search-result {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

/* 高亮匹配文本 */
.search-highlight {
    background: #fef08a;
    color: #1e293b;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 600;
}

@media (prefers-color-scheme: dark) {
    .search-highlight {
        background: #854d0e;
        color: #fef9c3;
    }
}

/* ─── 卡片统计 ──────────────────────────────── */
.cards-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px 12px;
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.cards-stats i {
    color: var(--primary);
    font-size: 14px;
}

/* ─── 表格视图（桌面端默认） ────────────────── */
.table-wrapper {
    display: none;
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 280px);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    -webkit-overflow-scrolling: touch;
}

.table-wrapper.show { display: block; }

.excel-table {
    width: max-content; min-width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.excel-table thead {
    position: sticky; top: 0; z-index: 2;
}

.excel-table th {
    background: var(--primary-gradient);
    color: #fff;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.3px;
    white-space: nowrap;
    border-right: 1px solid rgba(255,255,255,0.2);
    cursor: pointer;
    user-select: none;
    min-width: 90px;
    position: relative;
}

.excel-table th:hover { filter: brightness(1.1); }
.excel-table th:last-child { border-right: none; }

.excel-table th .sort-arrow {
    margin-left: 4px;
    font-size: 10px;
    opacity: 0.4;
}

.excel-table th.sorted-asc .sort-arrow { opacity: 1; }
.excel-table th.sorted-desc .sort-arrow { opacity: 1; }

.excel-table th.col-row-num {
    min-width: 48px; width: 48px;
    text-align: center;
    background: rgba(0,0,0,0.1);
    cursor: default;
}

.excel-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.excel-table td:last-child { border-right: none; }

.excel-table td.col-row-num {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
    background: var(--bg);
    border-right: 2px solid var(--border);
}

.excel-table tbody tr:nth-child(even) { background: var(--card-bg-alt); }
.excel-table tbody tr:hover { background: var(--primary-light); }
.excel-table tbody tr:last-child td { border-bottom: none; }

.excel-table td[data-editable="true"] {
    cursor: pointer;
}

.excel-table td[data-editable="true"]:hover {
    background: rgba(99,102,241,0.06);
    outline: 1px dashed var(--primary);
    outline-offset: -1px;
}

.excel-table td .empty {
    color: var(--text-tertiary);
    font-style: italic;
}

.excel-table .search-highlight {
    background: #fef08a;
    padding: 1px 2px;
    border-radius: 2px;
}

/* 列筛选行 */
.excel-table .filter-row td {
    padding: 4px 6px;
    background: var(--bg-alt);
    border-bottom: 2px solid var(--border);
}

.excel-table .filter-row td.col-row-num {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 12px;
}

.col-filter-input {
    width: 100%;
    min-width: 70px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    background: var(--card-bg);
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.15s;
}

.col-filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}

.col-filter-input::placeholder {
    color: var(--text-tertiary);
    font-size: 11px;
}

/* 清除筛选按钮 */
.btn-clear-filters {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s;
}

.btn-clear-filters:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

.btn-toggle-view {
    background: var(--bg-alt);
}

.btn-toggle-view:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ─── 卡片容器 ──────────────────────────────── */
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    padding-bottom: 20px;
}

/* ─── 卡片项 ──────────────────────────────────── */
.card-item {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    animation: cardEnter 0.4s var(--ease-bounce) backwards;
}

.card-item:nth-child(1) { animation-delay: 0.00s; }
.card-item:nth-child(2) { animation-delay: 0.04s; }
.card-item:nth-child(3) { animation-delay: 0.08s; }
.card-item:nth-child(4) { animation-delay: 0.12s; }
.card-item:nth-child(5) { animation-delay: 0.16s; }
.card-item:nth-child(6) { animation-delay: 0.20s; }
.card-item:nth-child(7) { animation-delay: 0.24s; }
.card-item:nth-child(8) { animation-delay: 0.28s; }

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card-item:hover {
    box-shadow: var(--shadow);
    transform: translateY(-3px);
    border-color: var(--primary);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--card-bg-alt);
    border-bottom: 1px solid var(--border-light);
}

.card-index {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-tertiary);
    background: var(--bg);
    padding: 3px 12px;
    border-radius: var(--radius-full);
    letter-spacing: 0.5px;
}

.card-actions {
    display: flex;
    gap: 4px;
}

.btn-card-edit {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--primary);
    cursor: pointer;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
    -webkit-tap-highlight-color: transparent;
}

.btn-card-edit:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-card-edit:active {
    transform: scale(0.93);
}

.card-body {
    padding: 14px 16px 16px;
}

.card-field {
    display: flex;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.5;
    padding: 4px 0;
    border-bottom: 1px dashed var(--border-light);
}

.card-field:last-child {
    margin-bottom: 0;
    border-bottom: none;
}

.field-label {
    font-weight: 600;
    color: var(--text-tertiary);
    min-width: 76px;
    flex-shrink: 0;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding-top: 1px;
}

.field-value {
    flex: 1;
    word-break: break-word;
    color: var(--text);
    font-weight: 500;
}

.field-value.empty {
    color: var(--text-tertiary);
    font-style: italic;
    font-weight: 400;
}

/* ─── 卡片颜色主题标记 ────────────────────────── */
.card-item[data-theme="0"] { --card-accent: #6366f1; }
.card-item[data-theme="1"] { --card-accent: #22c55e; }
.card-item[data-theme="2"] { --card-accent: #f59e0b; }
.card-item[data-theme="3"] { --card-accent: #ef4444; }
.card-item[data-theme="4"] { --card-accent: #3b82f6; }
.card-item[data-theme="5"] { --card-accent: #ec4899; }

.card-item {
    border-top: 3px solid var(--card-accent, var(--primary));
}

/* ─── 编辑弹窗 ──────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 16px;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.2s var(--ease);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 540px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: modalSlideUp 0.35s var(--ease-bounce);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h3 i {
    color: var(--primary);
}

.modal-close {
    background: var(--bg-alt);
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    line-height: 1;
}

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

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-body::-webkit-scrollbar {
    width: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.edit-field {
    margin-bottom: 16px;
}

.edit-field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.edit-field input,
.edit-field textarea,
.edit-field select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
    -webkit-appearance: none;
    appearance: none;
}

.edit-field textarea {
    min-height: 80px;
    resize: vertical;
}

.edit-field input:focus,
.edit-field textarea:focus,
.edit-field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.btn-cancel {
    padding: 11px 24px;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.btn-cancel:hover {
    background: var(--bg-alt);
    color: var(--text);
}

.btn-save {
    padding: 11px 24px;
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-save:active {
    transform: scale(0.96);
}

/* ─── Toast 提示 ──────────────────────────────── */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    z-index: 2000;
    opacity: 0;
    transition: all 0.35s var(--ease-bounce);
    pointer-events: none;
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.toast.success { background: linear-gradient(135deg, #22c55e, #16a34a); }
.toast.error   { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast.info    { background: var(--primary-gradient); }
.toast.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }

/* ─── 加载状态 ──────────────────────────────── */
.loading-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px;
}

.loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    animation: dotBounce 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ─── 移动底部导航 ──────────────────────────── */
.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 8px 16px calc(8px + var(--safe-bottom));
    z-index: 60;
    justify-content: space-around;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.mobile-bottom-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 10px;
    cursor: pointer;
    padding: 4px 16px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
    font-weight: 500;
}

.mobile-bottom-btn i {
    font-size: 20px;
}

.mobile-bottom-btn.active {
    color: var(--primary);
}

.mobile-bottom-btn:active {
    transform: scale(0.9);
}

/* ═══════════════════════════════════════════════════
   响应式设计
   ═══════════════════════════════════════════════════ */

/* 平板 & 小屏 */
@media (max-width: 1024px) {
    .cards-container {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* 手机端 */
@media (max-width: 768px) {
    :root {
        --header-height: 56px;
        --sidebar-width: 280px;
    }

    .app-header {
        padding: 0 8px;
    }

    .header-left h1 {
        font-size: 15px;
    }

    .btn-menu-toggle {
        display: flex;
    }

    /* 移动端 header-right 优化 — 登录按钮增大触控区 */
    .header-right {
        gap: 6px;
    }

    .header-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;   /* 防止被 flex 压缩 */
        font-size: 16px;
    }

    #loginLink {
        min-width: 60px;
        width: auto;
        padding: 0 12px;
        border-radius: 18px;
        font-size: 12px;
        font-weight: 600;
    }

    #loginLink::after {
        content: ' 登录';
    }

    .file-count-badge {
        font-size: 10px;
        padding: 2px 8px;
        white-space: nowrap;
    }

    /* 侧边栏：从左侧滑入 */
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        height: calc(100% - var(--header-height));
        height: calc(100dvh - var(--header-height));
        transform: translateX(-100%);
        z-index: 55;
        box-shadow: var(--shadow-xl);
        border-right: none;
        border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        padding: 12px;
    }

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

    .card-item {
        border-radius: var(--radius);
    }

    .card-body {
        padding: 12px 14px;
    }

    .card-field {
        font-size: 12px;
    }

    .field-label {
        min-width: 64px;
        font-size: 10px;
    }

    /* 文件详情栏调整 */
    .file-info-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 14px;
        gap: 8px;
    }

    .file-info-right {
        justify-content: flex-end;
    }

    .btn-sm {
        padding: 6px 12px;
        font-size: 12px;
    }

    /* Sheet 标签 */
    .sheet-tabs {
        margin-bottom: 14px;
        gap: 4px;
        padding-bottom: 4px;
    }

    .sheet-tab {
        padding: 7px 14px;
        font-size: 12px;
    }

    /* 搜索栏移动端 */
    .search-bar {
        margin-bottom: 12px;
        padding: 8px 10px;
        gap: 6px;
    }
    .search-bar input {
        font-size: 13px;
    }
    .search-result {
        font-size: 10px;
    }

    /* 弹窗全屏 */
    .modal-card {
        max-width: 100%;
        max-height: 90vh;
        border-radius: var(--radius-lg);
        margin: 8px;
    }

    .modal-header {
        padding: 14px 18px;
    }

    .modal-body {
        padding: 14px 18px;
    }

    .modal-footer {
        padding: 12px 18px;
    }

    .btn-cancel,
    .btn-save {
        padding: 10px 20px;
        font-size: 13px;
    }

    /* 底部导航栏 */
    .mobile-bottom-bar {
        display: flex;
    }

    /* 为底部导航留出空间 */
    .app-container {
        height: calc(100vh - var(--header-height) - 56px - var(--safe-bottom));
        height: calc(100dvh - var(--header-height) - 56px - var(--safe-bottom));
    }

    /* 移动端触控优化 — 增大触控区域 */
    .btn-card-edit {
        padding: 8px 16px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sheet-tab {
        padding: 10px 16px;
        min-height: 40px;
    }

    .file-item {
        padding: 14px 16px;
        min-height: 56px;
    }

    .btn-sm {
        padding: 8px 14px;
        min-height: 40px;
    }

    .btn-upload {
        padding: 10px 20px;
        min-height: 40px;
    }

    /* 移动端主内容区 z-index 优化 */
    .main-content {
        position: relative;
        z-index: 1;
    }

    /* 移动端侧边栏遮罩 — 强制 pointer-events 控制 */
    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .sidebar-overlay.show {
        display: block;
        pointer-events: auto;
    }

    /* 移动端卡片 — 优化滑动体验 */
    .card-item {
        -webkit-user-select: none;
        user-select: none;
    }

    .card-field {
        -webkit-user-select: text;
        user-select: text;
    }

    .toast {
        bottom: 76px;
        font-size: 13px;
        padding: 10px 18px;
    }

    /* 欢迎屏调整 */
    .welcome-icon-wrapper {
        width: 90px;
        height: 90px;
    }

    .welcome-icon {
        font-size: 38px;
    }

    .welcome-screen h2 {
        font-size: 17px;
    }
}

/* 小屏手机 */
@media (max-width: 380px) {
    .cards-container {
        gap: 10px;
    }

    .card-header {
        padding: 10px 12px;
    }

    .card-body {
        padding: 10px 12px;
    }

    .btn-card-edit {
        padding: 4px 10px;
        font-size: 11px;
    }

    .sidebar {
        width: 260px;
        min-width: 260px;
    }
}

/* 横屏手机 */
@media (max-height: 480px) and (orientation: landscape) {
    .modal-card {
        max-height: 85vh;
    }

    .modal-body {
        max-height: 50vh;
    }
}
