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

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #4f46e5;
    --bg: #f1f5f9;
    --card-bg: #fff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --info: #3b82f6;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    display: flex;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ==================== 侧边栏 ==================== */
.sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: #cbd5e1;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 15px;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: rgba(79,70,229,0.2);
    color: #fff;
    border-left-color: var(--sidebar-active);
    font-weight: 600;
}

.nav-icon { font-size: 18px; }

/* ==================== 主内容区 ==================== */
.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 28px 32px;
    min-height: 100vh;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.25s ease; }

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

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
}

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

.btn-primary:hover { background: var(--primary-hover); }

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

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

.btn-cancel {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-cancel:hover { background: #e2e8f0; }

.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover { background: #f8fafc; }

.btn-edit {
    background: #eef2ff;
    color: var(--primary);
    padding: 4px 10px;
    font-size: 12px;
}

.btn-edit:hover { background: #e0e7ff; }

.btn-delete {
    background: #fef2f2;
    color: var(--danger);
    padding: 4px 10px;
    font-size: 12px;
}

.btn-delete:hover { background: #fee2e2; }

/* ==================== 表格 ==================== */
.table-wrapper {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.data-table thead {
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
}

.data-table th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #f1f5f9;
}

.data-table tbody tr:hover { background: #f8fafc; }

.data-table tbody tr:last-child td { border-bottom: none; }

/* 操作按钮列 */
.data-table .action-cell {
    white-space: nowrap;
}
.data-table .action-cell .btn + .btn {
    margin-left: 4px;
}

/* 可点击内联编辑 */
.editable {
    cursor: pointer;
    border-bottom: 2px dotted #cbd5e1;
    transition: all 0.15s;
}

.editable:hover {
    background: #eef2ff;
    border-bottom-color: var(--primary);
}

.editable-date .placeholder {
    color: #cbd5e1;
    font-size: 12px;
}

.inline-input {
    border: 2px solid var(--primary);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

/* ==================== 绩效表格特殊列 ==================== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-perfect { background: #d1fae5; color: #065f46; }
.badge-good    { background: #dbeafe; color: #1e40af; }
.badge-improve { background: #fef3c7; color: #92400e; }
.badge-fail    { background: #fee2e2; color: #991b1b; }
.badge-yes     { background: #d1fae5; color: #065f46; }
.badge-no      { background: #fee2e2; color: #991b1b; }

.progress-bar-wrap {
    width: 100px;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

/* ==================== 考勤页面 ==================== */
.month-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

.month-picker span {
    font-size: 16px;
    font-weight: 600;
    min-width: 130px;
    text-align: center;
}

.attendance-legend {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.legend-hint {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

.attendance-wrapper {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: auto;
}

.attendance-table {
    border-collapse: collapse;
    min-width: 100%;
}

.attendance-table th,
.attendance-table td {
    border: 1px solid var(--border);
    padding: 6px 4px;
    text-align: center;
    font-size: 12px;
    min-width: 36px;
    height: 34px;
}

.attendance-table .col-info {
    min-width: 50px;
    text-align: left;
    padding: 6px 10px;
}

.attendance-table thead th {
    background: #f8fafc;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.attendance-table .col-no {
    min-width: 70px;
    text-align: left;
    padding-left: 10px;
}

.attendance-table .col-name {
    min-width: 80px;
    text-align: left;
    font-weight: 500;
}

.attendance-table .day-header {
    min-width: 34px;
    width: 34px;
    font-size: 11px;
}

.attendance-table .day-header.weekend {
    color: var(--danger);
}

/* 固定左侧列 */
.attendance-table .sticky-left {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 2;
}

.attendance-table thead .sticky-left {
    background: #f8fafc;
    z-index: 3;
}

.attendance-table tbody tr:hover .sticky-left {
    background: #f8fafc;
}

/* 考勤单元格状态颜色 */
.cell-leave  { background: #fef3c7 !important; cursor: pointer; }
.cell-absent { background: #fee2e2 !important; cursor: pointer; }
.cell-rest   { background: #dbeafe !important; cursor: pointer; }
.cell-normal { background: #fff; cursor: pointer; }
.cell-normal:hover { background: #f1f5f9 !important; }

.cell-leave:hover  { filter: brightness(0.95); }
.cell-absent:hover { filter: brightness(0.95); }
.cell-rest:hover   { filter: brightness(0.95); }

/* 不可用日期(超出当月天数) */
.cell-disabled {
    background: #f9fafb !important;
    cursor: default;
    color: #d1d5db;
}

/* ==================== 弹窗 ==================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 0;
}

.modal-lg { max-width: 640px; }

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

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

.modal form {
    padding: 20px 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* ==================== 表单 ==================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
}

.required { color: var(--danger); }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
    font-family: inherit;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group { flex: 1; }

/* ==================== 右键菜单 ==================== */
.context-menu {
    display: none;
    position: fixed;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 300;
    min-width: 150px;
    padding: 6px 0;
    border: 1px solid var(--border);
}

.context-menu.active { display: block; }

.context-item {
    padding: 9px 18px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.context-item:hover { background: #f1f5f9; }

.context-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 400;
    padding: 12px 22px;
    border-radius: var(--radius);
    color: #fff;
    font-weight: 500;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    pointer-events: none;
}

.toast.show { transform: translateX(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .sidebar { width: 60px; min-width: 60px; }
    .sidebar-header h2 { display: none; }
    .nav-item span:last-child { display: none; }
    .main-content { margin-left: 60px; padding: 16px; }
    .form-row { flex-direction: column; gap: 0; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}
