/* ===== 云稷科技绩效管理系统 - 样式表 ===== */

:root {
    --primary: #4a90d9;
    --primary-dark: #357abd;
    --primary-light: #e8f1fc;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --text-muted: #bdc3c7;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --border: #e1e8ed;
    --sidebar-bg: #2c3e50;
    --sidebar-text: #ecf0f1;
    --sidebar-active: #34495e;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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.6;
}

/* ===== Layout ===== */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

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

.logo {
    font-size: 32px;
    margin-bottom: 8px;
}

.company-name {
    font-size: 18px;
    font-weight: 700;
}

.system-name {
    font-size: 12px;
    opacity: 0.6;
    margin-top: 4px;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
    background: var(--sidebar-active);
    border-left: 3px solid var(--primary);
    padding-left: 21px;
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
}

.user-role {
    font-size: 12px;
    opacity: 0.6;
}

.logout-btn {
    display: block;
    text-align: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 13px;
    transition: all 0.2s;
}

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

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px 32px;
    min-width: 0;
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

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

.period-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.period-selector select {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

/* ===== Flash Messages ===== */
.flash-container {
    margin-bottom: 16px;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 14px;
}

.flash-success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid var(--success); }
.flash-error { background: #ffebee; color: #c62828; border-left: 4px solid var(--danger); }

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-badge {
    font-size: 12px;
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: 12px;
}

.card-body {
    padding: 24px;
}

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

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
}

.stat-card.stat-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
}

.stat-card.stat-success {
    background: linear-gradient(135deg, #66bb6a, #43a047);
    color: #fff;
}

.stat-label {
    font-size: 13px;
    opacity: 0.8;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-value-text {
    font-size: 18px;
    font-weight: 600;
    margin-top: 4px;
}

.stat-grade {
    font-size: 13px;
    margin-top: 6px;
    padding: 2px 12px;
    border-radius: 12px;
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
}

.grade-A { color: #4caf50; }
.grade-B { color: #2196f3; }
.grade-C { color: #ff9800; }
.grade-D { color: #f44336; }
.grade-E { color: #9e9e9e; }

.grade-badge {
    padding: 2px 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
}
.grade-badge.grade-A { background: #e8f5e9; color: #2e7d32; }
.grade-badge.grade-B { background: #e3f2fd; color: #1565c0; }
.grade-badge.grade-C { background: #fff3e0; color: #e65100; }
.grade-badge.grade-D { background: #ffebee; color: #c62828; }
.grade-badge.grade-E { background: #f5f5f5; color: #616161; }

/* ===== AI Summary ===== */
.ai-summary {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text);
}

.ai-note {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 12px;
    color: var(--text-light);
}

/* ===== Dimensions ===== */
.dimensions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.dimension-item {
    background: #f8f9fb;
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
}

.dim-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.dim-name {
    font-weight: 600;
    font-size: 15px;
}

.dim-source {
    font-size: 11px;
    color: var(--text-light);
    background: #eef1f5;
    padding: 2px 8px;
    border-radius: 10px;
}

.dim-score-bar {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

.dim-score {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.dim-weight {
    font-size: 12px;
    color: var(--text-light);
}

.dim-bar-container {
    height: 8px;
    background: #e0e4e8;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.dim-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.dim-basis {
    margin-bottom: 8px;
}

.dim-basis-label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.dim-basis p {
    font-size: 13px;
    line-height: 1.6;
}

.dim-detail {
    margin-top: 8px;
}

.dim-detail summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--primary);
    padding: 4px 0;
}

.dim-detail pre {
    margin-top: 8px;
    background: #1e2a36;
    color: #a8b8cc;
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    overflow-x: auto;
    line-height: 1.5;
}

/* ===== Tables ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: #f8f9fb;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-light);
}

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

.data-table tfoot td {
    font-weight: 600;
    background: #f8f9fb;
}

.bonus-amount {
    color: var(--success);
    font-weight: 700;
}

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

/* ===== Badges ===== */
.badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-warning { background: #fff3e0; color: #e65100; }
.badge-danger { background: #ffebee; color: #c62828; }
.badge-default { background: #f5f5f5; color: #616161; }

/* ===== Buttons ===== */
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-text {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
}

.btn-text:hover { text-decoration: underline; }

.btn-sm {
    padding: 4px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #f57c00; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #d32f2f; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #388e3c; }

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    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(74, 144, 217, 0.1);
}

.textarea-code {
    font-family: "Courier New", monospace;
    font-size: 13px;
    line-height: 1.5;
}

.form-inline {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-inline .form-group {
    margin-bottom: 0;
}

.action-cell {
    white-space: nowrap;
}

.inline-form {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    margin-right: 4px;
}

/* ===== Bonus ===== */
.bonus-formula {
    margin-top: 16px;
    padding: 12px 16px;
    background: #f8f9fb;
    border-radius: var(--radius);
    border-left: 3px solid var(--primary);
}

.bonus-formula p {
    font-size: 13px;
    margin-bottom: 4px;
}

.bonus-detail-item {
    padding: 16px;
    background: #f8f9fb;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.bonus-detail-item h4 {
    margin-bottom: 12px;
    font-size: 15px;
}

.bonus-calc {
    max-width: 400px;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 14px;
}

.calc-result {
    border-bottom: none;
    border-top: 2px solid var(--primary);
    margin-top: 8px;
    padding-top: 12px;
    font-size: 16px;
    font-weight: 700;
}

/* ===== Info List ===== */
.info-list {
    display: grid;
    gap: 16px;
}

.info-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.info-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.info-item strong {
    font-size: 14px;
    display: block;
    margin-bottom: 4px;
}

.info-item p {
    font-size: 13px;
    color: var(--text-light);
}

/* ===== Config ===== */
.config-desc {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 12px;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

/* ===== Error Page ===== */
.error-page {
    text-align: center;
    padding: 80px 20px;
}

.error-code {
    font-size: 72px;
    font-weight: 700;
    color: var(--text-muted);
}

.error-page p {
    font-size: 18px;
    color: var(--text-light);
    margin: 16px 0 24px;
}

/* ===== Login Page ===== */
.login-page {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px 32px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.login-header p {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 4px;
}

.login-flash {
    margin-bottom: 20px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.login-form input {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    width: 100%;
    transition: all 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.login-demo {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.login-demo p {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.login-demo ul {
    list-style: none;
    font-size: 12px;
    color: var(--text-light);
}

.login-demo li {
    padding: 2px 0;
}

.login-demo code {
    background: #f0f4f8;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    color: var(--primary-dark);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

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

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .dimensions-grid {
        grid-template-columns: 1fr;
    }

    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .data-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 8px;
    }
}

/* ===== 绩效工资公式样式 ===== */
.formula-box {
    text-align: center;
}

.formula-main {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--primary);
    padding: 12px 20px;
    background: var(--primary-light);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.formula-table {
    width: 100%;
    max-width: 600px;
    margin: 0 auto 16px;
    border-collapse: collapse;
}

.formula-table th {
    background: var(--bg);
    padding: 10px;
    font-size: 13px;
    border-bottom: 2px solid var(--border);
}

.formula-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.formula-table .active-row {
    background: var(--primary-light);
    font-weight: 600;
}

.formula-note {
    color: var(--text-light);
    font-size: 12px;
    margin-top: 8px;
}

/* ===== 结构化原始数据（detail_json 替代 <pre> 渲染） ===== */
.raw-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 10px;
}
.raw-stat {
    background: #f5f7fa;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 13px;
    color: #333;
}
.raw-stat b {
    color: #4a90d9;
    font-size: 15px;
}
.raw-block {
    margin-top: 12px;
}
.raw-block-title {
    font-weight: 600;
    font-size: 13px;
    color: #4a90d9;
    margin-bottom: 6px;
}
.raw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 4px;
}
.raw-table th, .raw-table td {
    border: 1px solid #e3e6ea;
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
}
.raw-table th {
    background: #f5f7fa;
    font-weight: 600;
    color: #555;
}
.raw-table code {
    background: #f8f9fb;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 12px;
}
.raw-date {
    white-space: nowrap;
    color: #666;
    font-family: monospace;
    font-size: 12px;
}
.week-row, .report-row {
    border-left: 3px solid #4a90d9;
    padding: 6px 12px;
    margin-bottom: 8px;
    background: #fafbfc;
    border-radius: 0 4px 4px 0;
}
.week-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 13px;
}
.week-pct {
    color: #4a90d9;
    font-weight: 600;
}
.week-content, .report-content {
    background: #fff;
    padding: 8px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    font-family: inherit;
    font-size: 12px;
    color: #333;
    line-height: 1.5;
}
.raw-formula {
    margin-top: 10px;
    padding: 8px 12px;
    background: #fff8e1;
    border-left: 3px solid #ffa000;
    color: #5d4037;
    font-size: 12px;
    border-radius: 0 4px 4px 0;
}
.raw-empty {
    color: #999;
    padding: 8px;
    text-align: center;
    font-style: italic;
}
