:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
    max-width: 1100px; margin: 0 auto; padding: 0 20px;
    display: flex; align-items: center; gap: 24px; height: 56px;
}
.brand { font-weight: 700; color: var(--primary); text-decoration: none; font-size: 16px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
    color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 6px; font-size: 13.5px;
}
.nav a:hover { background: #f1f5f9; color: var(--text); }
.nav a.active { background: #eff6ff; color: var(--primary); font-weight: 600; }
.user-menu { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 20px; }

.card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; margin-bottom: 20px;
}
.card h2 { margin-top: 0; font-size: 15px; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--primary); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.table th { color: var(--muted); font-weight: 600; background: #fafbfc; }
.table tbody tr:hover { background: #f8fafc; }
.table-summary { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.bulk-bar { display: flex; align-items: center; gap: 16px; padding: 8px 0 14px; font-size: 13.5px; }
.bulk-select-all { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.bulk-bar .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.row-actions { display: flex; gap: 10px; }
.inline-form { display: inline; }
.inline-fields { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-fields input, .inline-fields select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; }

.filter-bar { display: flex; gap: 16px; flex-wrap: end; align-items: flex-end; flex-wrap: wrap; }
.filter-bar label { display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); gap: 4px; }
.filter-bar input, .filter-bar select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13.5px; min-width: 140px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid input, .form-grid select { padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; color: var(--text); }
.quick-dates { display: inline-flex; gap: 10px; margin-top: 4px; }
.quick-dates button { font-size: 12.5px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.hint { color: var(--muted); font-size: 12px; font-weight: normal; }

.drop-zone {
    border: 2px dashed #93b4f0;
    border-radius: var(--radius);
    padding: 28px 16px;
    text-align: center;
    background: #f7faff;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}
.drop-zone p { margin: 4px 0; font-size: 13.5px; color: var(--text); }
.drop-zone .hint { margin: 4px 0 0; }
.drop-zone.drag-over { border-color: var(--primary); background: #eef4ff; }
.drop-zone-icon { font-size: 26px; line-height: 1; margin-bottom: 6px; }
.upload-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.upload-actions .btn { padding: 8px 16px; }
.file-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: var(--card-bg);
}
.file-list li .file-name { flex: 1; word-break: break-all; }
.file-list li .file-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ===== 拍照裁剪弹窗（框选后再做扫描效果处理）===== */
.crop-modal-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .72);
    display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px;
}
.crop-modal-overlay[hidden] { display: none; }
.crop-modal {
    background: #111827; border-radius: 10px; padding: 14px; width: 100%; max-width: 520px;
    display: flex; flex-direction: column; gap: 12px; max-height: 92vh;
}
.crop-modal h3 { color: #fff; margin: 0; font-size: 15px; }
.crop-stage {
    position: relative; touch-action: none; user-select: none; line-height: 0;
    background: #000; border-radius: 6px; overflow: hidden;
    width: fit-content; max-width: 100%; margin: 0 auto;
}
.crop-stage img { display: block; max-width: 100%; max-height: 60vh; width: auto; height: auto; }
.crop-box {
    position: absolute; border: 2px dashed #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.6);
    cursor: move; touch-action: none;
}
.crop-handle {
    position: absolute; width: 22px; height: 22px; background: #fff; border: 2px solid var(--primary);
    border-radius: 50%; touch-action: none;
    transform: translate(-50%, -50%);
}
.crop-handle.nw { top: 0; left: 0; cursor: nwse-resize; }
.crop-handle.ne { top: 0; left: 100%; cursor: nesw-resize; }
.crop-handle.sw { top: 100%; left: 0; cursor: nesw-resize; }
.crop-handle.se { top: 100%; left: 100%; cursor: nwse-resize; }
.crop-options { display: flex; align-items: center; gap: 8px; color: #e2e8f0; font-size: 13px; }
.crop-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.crop-actions .btn { padding: 9px 16px; }

.btn { display: inline-block; padding: 9px 18px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; font-size: 13.5px; font-weight: 600; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 13px; text-decoration: none; }
.btn-link.danger { color: var(--danger); }

.tag { padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.tag-ok { background: #dcfce7; color: #166534; }
.tag-off { background: #fee2e2; color: #991b1b; }

.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13.5px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert ul { margin: 0; padding-left: 18px; }

.muted { color: var(--muted); }

.pagination { display: flex; gap: 6px; margin-top: 16px; }
.pagination a { padding: 6px 11px; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; color: var(--text); font-size: 13px; }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.login-card { width: 320px; max-width: 100%; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 18px; margin: 0 0 2px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { padding: 10px; border: 1px solid var(--border); border-radius: 6px; }

/* ===== 员工端：极简顶栏 + 底部固定导航 ===== */
.topbar-simple .topbar-inner { justify-content: center; height: 48px; }
.topbar-simple .brand { color: var(--text); font-size: 15px; }

body.has-bottom-nav { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
.container-employee { max-width: 480px; padding: 14px 14px 16px; }

.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: #fff; border-top: 1px solid var(--border);
    display: flex; padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 4px 10px; color: var(--muted); text-decoration: none; font-size: 12px;
}
.bottom-nav-item.active { color: var(--primary); font-weight: 600; }
.bottom-nav-icon { font-size: 20px; line-height: 1; }

/* ===== 员工个人主页：尽量一屏放下，最近记录区域内部单独滚动 ===== */
.my-home { display: flex; flex-direction: column; gap: 12px; height: calc(100dvh - 48px - 64px - 28px); min-height: 420px; }
.my-home-greeting { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.my-home-name { font-size: 18px; font-weight: 700; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.my-home-stats { margin-bottom: 0; flex-shrink: 0; }
.my-home-recent { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-bottom: 0; }
.my-home-recent h2 { flex-shrink: 0; }
.my-home-recent-list { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.recent-list li { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.recent-list li:last-child { border-bottom: none; }
.recent-list-main { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; }
.recent-list-item-name { font-weight: 600; }
.recent-list-amount { color: var(--primary); font-weight: 700; }
.recent-list-sub { font-size: 12px; margin-top: 2px; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.table-scroll .table { min-width: 640px; }

@media (max-width: 720px) {
    .container { padding: 16px 12px 48px; }
    .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
    .nav { order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 2px; }
    .nav a { padding: 9px 12px; white-space: nowrap; }
    .user-menu { margin-left: auto; }

    .page-head { flex-wrap: wrap; gap: 10px; }
    .page-head h1 { font-size: 18px; }
    .page-head .btn { width: 100%; text-align: center; }

    .card { padding: 16px; }
    .stat-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-value { font-size: 22px; }

    .form-grid { grid-template-columns: 1fr; }
    .form-grid input, .form-grid select { font-size: 16px; padding: 11px 10px; } /* >=16px 避免 iOS 输入框自动放大 */

    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar label, .filter-bar select, .filter-bar input { width: 100%; min-width: 0; }
    .filter-bar .btn, .filter-bar .btn-link { width: 100%; text-align: center; }

    .inline-fields { flex-direction: column; align-items: stretch; }
    .inline-fields input, .inline-fields select, .inline-fields .btn { width: 100%; }

    .row-actions { flex-direction: column; gap: 6px; align-items: flex-start; }
    .btn-link { font-size: 14px; padding: 4px 0; } /* 触屏点击区域更大一些 */

    .bulk-bar { flex-wrap: wrap; }
    .bulk-bar .btn { width: 100%; }

    .upload-actions { flex-direction: column; }
    .upload-actions .btn { width: 100%; }

    .crop-actions { flex-direction: column-reverse; }
    .crop-actions .btn { width: 100%; }

    .pagination { flex-wrap: wrap; }
}
