/* ========== Analytics Module ========== */

/* --- Filters bar --- */
.analytics-filter {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.analytics-filter label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}
.analytics-filter select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg);
    outline: none;
    min-width: 120px;
    color: var(--text);
}
.analytics-filter select:focus {
    border-color: var(--primary);
    background: #fff;
}
.analytics-filter .filter-sep {
    width: 1px;
    height: 24px;
    background: var(--border);
}

/* --- Ranking page --- */
.ranking-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.ranking-summary-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    box-shadow: var(--shadow);
    padding: 14px 16px;
}
.ranking-summary-item .label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.ranking-summary-item .value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-x: auto;
}
.ranking-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: box-shadow .15s, border-color .15s;
    min-width: 900px;
}
.ranking-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.ranking-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    background: var(--bg);
    color: var(--text-secondary);
}
.ranking-card:nth-child(1) .ranking-badge { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.ranking-card:nth-child(2) .ranking-badge { background: linear-gradient(135deg, #94a3b8, #64748b); color: #fff; }
.ranking-card:nth-child(3) .ranking-badge { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }

.ranking-name {
    width: 140px;
    min-width: 140px;
    max-width: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.ranking-member-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ranking-name .ranking-team {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-stat {
    text-align: center;
    min-width: 72px;
    flex-shrink: 0;
}
.ranking-stat .stat-val {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.ranking-stat .stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.target-pass {
    display: inline-block;
    color: #166534;
    background: #dcfce7;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}
.target-fail {
    display: inline-block;
    color: #991b1b;
    background: #fee2e2;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

/* --- Progress form --- */
.progress-form-wrap {
    max-width: 800px;
}
.progress-form {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 20px 24px;
}
.progress-form .form-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}
.progress-field {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.progress-field label {
    width: 120px;
    font-size: 13px;
    font-weight: 500;
    text-align: right;
    flex-shrink: 0;
}
.progress-field input {
    flex: 1;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    background: var(--bg);
    max-width: 300px;
}
.progress-field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: #fff;
}
.progress-field .unit {
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.progress-field .hint {
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- Targets table --- */
.targets-wrap {
    overflow-x: auto;
}
.targets-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    font-size: 13px;
}
.targets-table th, .targets-table td {
    padding: 10px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
}
.targets-table th {
    background: #F8FAFB;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    position: sticky;
    top: 0;
    z-index: 2;
    white-space: nowrap;
}
.targets-table td:first-child {
    text-align: left;
    font-weight: 500;
    white-space: nowrap;
}
.targets-table input {
    width: 100px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    text-align: center;
    outline: none;
    background: #fff;
}
.targets-table input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}
.targets-team-row td {
    background: #F8FAFB;
    font-weight: 600;
    font-size: 12px;
    color: var(--primary);
    text-align: left !important;
}

/* --- Targets grouped header & new columns --- */
.targets-table .targets-group-header {
    font-size: 13px;
    font-weight: 700;
    border-bottom: 2px solid var(--primary);
}
.targets-table .targets-group-current {
    background: #F0F4FF;
    color: var(--primary);
}
.targets-table .targets-group-prev {
    background: #F0FAF4;
    color: #166534;
    border-bottom-color: #16a34a;
}
.targets-table .th-prev {
    font-size: 11px;
    color: var(--text-secondary);
    background: #F8FBF9;
}
.targets-table .actual-input {
    width: 100px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    text-align: center;
    outline: none;
    background: #F8FBF9;
}
.targets-table .actual-input:focus {
    border-color: #16a34a;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.15);
    background: #fff;
}

/* --- Members page --- */
.members-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.team-group {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.team-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #F8FAFB;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
}
.team-group-header h4 {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.team-group-header .count {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--border);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}
.team-group-body {
    padding: 12px 18px;
}
.member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.member-item:last-child { border-bottom: none; }
.member-item .member-name {
    font-size: 14px;
    font-weight: 500;
}
.member-item .member-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}
.member-item .member-status.active { background: #dcfce7; color: #166534; }
.member-item .member-status.inactive { background: #fee2e2; color: #991b1b; }
.member-item .member-actions {
    display: flex;
    gap: 6px;
}

/* --- Wechat table --- */
.wechat-table-wrap {
    overflow-x: auto;
}
.wechat-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    font-size: 13px;
    min-width: 900px;
}
.wechat-table th, .wechat-table td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}
.wechat-table th {
    background: #F8FAFB;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    position: sticky;
    top: 0;
    z-index: 1;
}
.wechat-table tr:last-child td { border-bottom: none; }
.wechat-table tbody tr:hover { background: var(--bg-hover); }
.wechat-table .td-wechat-id { font-family: monospace; font-size: 13px; }
.wechat-table .td-num { text-align: right; font-variant-numeric: tabular-nums; }
.wechat-table .td-actions { white-space: nowrap; }
.wechat-summary { margin-top: 10px; font-size: 13px; color: var(--text-secondary); text-align: right; }

/* --- Transfer timeline (analytics) --- */
.transfer-list {
    padding: 8px 0;
}
.transfer-list .transfer-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    position: static;
}
.transfer-list .transfer-item:last-child { border-bottom: none; }
.transfer-list .transfer-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    margin-top: 5px;
    position: static;
    border: none;
}
.transfer-list .transfer-info .transfer-names {
    font-weight: 500;
    margin-bottom: 2px;
}
.transfer-list .transfer-info .transfer-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- Indicator list --- */
.indicator-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.indicator-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.indicator-item .ind-label {
    font-size: 14px;
    font-weight: 600;
}
.indicator-item .ind-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
}
.indicator-item .ind-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ind-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}
.ind-tag.target { background: #dbeafe; color: #1e40af; }
.ind-tag.progress { background: #dcfce7; color: #166534; }
.ind-tag.computed { background: #fef3c7; color: #92400e; }
.ind-group-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 0 4px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 8px;
}

/* --- Import area --- */
.import-area {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    border: 2px dashed var(--border);
    max-width: 500px;
}
.import-area .import-icon {
    font-size: 40px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.import-area p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .ranking-card {
        min-width: 800px;
        gap: 8px;
        padding: 10px 12px;
    }
    .ranking-name { width: 100px; min-width: 100px; max-width: 100px; }
    .ranking-stat { min-width: 60px; }
    .progress-field { flex-wrap: wrap; }
    .progress-field label { width: auto; text-align: left; }
    .analytics-filter { flex-direction: column; align-items: stretch; }
}

/* --- Rankable label --- */
.rankable-label {
    font-size: 12px;
    margin-left: 6px;
    vertical-align: middle;
}
.rankable-label.yes { color: #166534; }
.rankable-label.no { color: #991b1b; }

/* --- Members manage table --- */
.members-manage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.members-manage-table th, .members-manage-table td {
    padding: 10px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
}
.members-manage-table th {
    background: #F8FAFB;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
}

/* --- Settings page --- */
.setting-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px 24px;
    margin-bottom: 16px;
}
.setting-section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}
.setting-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
.setting-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.setting-row label {
    font-size: 13px;
    font-weight: 500;
    min-width: 80px;
}
.setting-row select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: #fff;
    outline: none;
    min-width: 120px;
}
.setting-row select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* --- Week preview table --- */
.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 8px;
}
.preview-table th, .preview-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}
.preview-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    background: #F8FAFB;
}
.preview-table tr.current {
    background: var(--primary-light);
    font-weight: 600;
}
.preview-table tr.current td { color: var(--primary); }

/* --- Progress list view --- */
.progress-list-wrap {
    overflow-x: auto;
}
.progress-list-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    font-size: 13px;
    min-width: 800px;
}
.progress-list-table th, .progress-list-table td {
    padding: 10px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
}
.progress-list-table th {
    background: #F8FAFB;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    position: sticky;
    top: 0;
    z-index: 2;
    white-space: nowrap;
}
.progress-list-table .clickable-row {
    cursor: pointer;
    transition: background .15s;
}
.progress-list-table .clickable-row:hover {
    background: var(--bg-hover);
}
.progress-list-table .week-cell {
    white-space: nowrap;
    font-size: 13px;
}
.progress-summary {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: right;
}

/* --- View toggle --- */
.view-toggle {
    display: flex;
    gap: 4px;
}

/* --- Filter inline layout fix --- */
.analytics-filter .view-toggle + .filter-sep {
    margin-left: 4px;
}

/* --- Form row (analytics scope) --- */
.progress-form .form-row { display: flex; gap: 12px; }
.progress-form .form-row .form-group { flex: 1; }

/* ========== Progress UI Upgrade ========== */

/* --- Stats summary row --- */
.progress-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.progress-stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}
.progress-stat-card .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.progress-stat-card .stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

/* --- Inline editable table inputs --- */
.progress-list-table .progress-input {
    width: 90px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    text-align: center;
    outline: none;
    background: #fff;
}
.progress-list-table .progress-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}
.progress-input-readonly {
    background: #f5f5f5 !important;
    color: #999 !important;
    cursor: not-allowed !important;
    border-color: #e5e5e5 !important;
}
.progress-input-readonly:focus {
    border-color: #e5e5e5 !important;
    box-shadow: none !important;
}
.progress-list-table tbody tr:hover td {
    background: #FAFBFC;
}

/* --- Team separator row --- */
.progress-team-row td {
    background: #F8FAFB;
    font-weight: 600;
    font-size: 12px;
    color: var(--primary);
    text-align: left !important;
}

/* --- Progress UI responsive --- */
@media (max-width: 768px) {
    .progress-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .progress-list-table .progress-input {
        width: 70px;
        font-size: 12px;
    }
}
