/* 業績（pages/hrPerformance.js）。手機版的卡片排法在 css/mobile.css。 */

.perf-tabs {
    display: flex;
    max-width: 560px;
    margin-bottom: 14px;
    border-bottom: 1px solid #e5e7eb;
}

.perf-tab {
    flex: 1;
    padding: 10px 0;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    color: #6b7280;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.perf-tab.active {
    color: #111827;
    border-bottom-color: var(--primary-color, #2563eb);
}

.perf-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 8px;
}

.perf-custom {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.perf-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: #6b7280;
}

.perf-field select,
.perf-field input {
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    font-size: 14px;
}

.perf-export {
    margin-left: auto;
    white-space: nowrap;
}

.perf-export:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.perf-range-note {
    margin-bottom: 12px;
    color: #6b7280;
    font-size: 13px;
}

/* 總覽卡片 */
.perf-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.perf-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}

.perf-card span {
    color: #6b7280;
    font-size: 13px;
}

.perf-card strong {
    font-size: 22px;
    font-variant-numeric: tabular-nums;
}

.perf-empty {
    padding: 28px 16px;
    background: white;
    border: 1px dashed #d1d5db;
    border-radius: 10px;
    color: #6b7280;
    text-align: center;
}

/* 全員業績：每人一列 */
.perf-people {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}

.perf-person-head,
.perf-person-row {
    display: grid;
    grid-template-columns: minmax(140px, 1.6fr) repeat(4, minmax(80px, 1fr)) minmax(120px, 1.4fr);
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    text-align: left;
}

.perf-person-head {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    color: #6b7280;
    font-size: 13px;
}

.perf-person-row {
    background: transparent;
    border: none;
    border-bottom: 1px solid #f3f4f6;
    border-radius: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.perf-person-row:hover:not(:disabled) {
    background: #f9fafb;
}

.perf-person-row:disabled {
    cursor: default;
    color: #9ca3af;
}

.perf-person.is-open .perf-person-row {
    background: #eff6ff;
}

.perf-person-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.perf-person-row span {
    font-variant-numeric: tabular-nums;
}

/* 佔比：一條橫條 + 百分比 */
.perf-share {
    position: relative;
    display: flex;
    align-items: center;
    height: 22px;
    background: #f3f4f6;
    border-radius: 6px;
    overflow: hidden;
}

.perf-share i {
    position: absolute;
    inset: 0 auto 0 0;
    background: #bfdbfe;
}

.perf-share b {
    position: relative;
    padding-left: 8px;
    font-size: 12px;
    font-weight: 600;
}

/* 訂單清單（我的業績，或展開某個人之後） */
.perf-orders {
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}

.perf-person .perf-orders {
    border: none;
    border-radius: 0;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.perf-order {
    display: grid;
    grid-template-columns: 110px minmax(120px, 1fr) 90px 110px 110px;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
}

.perf-order:last-child {
    border-bottom: none;
}

.perf-order-customer {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.perf-order-status {
    color: #6b7280;
    font-size: 13px;
}

.perf-order-amount,
.perf-order-paid {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* 這幾個元素用 hidden 屬性顯示／隱藏；上面的 display 設定會蓋掉它，所以要明講 */
.perf-tabs[hidden],
.perf-toolbar[hidden],
.perf-custom[hidden],
.perf-field[hidden] {
    display: none;
}

/* 訂單清單的欄位標題（只在電腦版顯示；手機版每個數字前面自己帶欄位名稱） */
.perf-orders-head {
    display: grid;
    grid-template-columns: 110px minmax(120px, 1fr) 90px 110px 110px;
    gap: 8px;
    padding: 8px 16px;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    color: #6b7280;
    font-size: 12px;
}

.perf-orders-head span:nth-child(n+4) {
    text-align: right;
}

/* 卡片下面的小註解（例如「款項已核帳」） */
.perf-card em {
    color: #9ca3af;
    font-size: 12px;
    font-style: normal;
}

/* 有分潤欄位時，全員表多兩欄、訂單清單多一欄 */
.perf-people.has-commission .perf-person-head,
.perf-people.has-commission .perf-person-row {
    grid-template-columns: minmax(130px, 1.5fr) repeat(4, minmax(78px, 1fr)) repeat(2, minmax(92px, 1fr)) minmax(110px, 1.2fr);
}

.perf-orders.has-commission .perf-orders-head,
.perf-orders.has-commission .perf-order {
    grid-template-columns: 110px minmax(120px, 1fr) 90px 110px 110px 130px;
}

.perf-order-commission {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.perf-order-commission small {
    color: #9ca3af;
    font-size: 11px;
    font-weight: 400;
}

.perf-orders.has-commission .perf-orders-head span:nth-child(6) {
    text-align: right;
}

/* 分潤規則分頁 */
.perf-rules {
    max-width: 820px;
}

.perf-rules.is-busy {
    opacity: .6;
    pointer-events: none;
}

.perf-rules-title {
    margin: 18px 0 4px;
    font-size: 18px;
}

.perf-rules-hint {
    margin: 0 0 10px;
    color: #6b7280;
    font-size: 13px;
}

.perf-rule-person {
    margin-bottom: 8px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}

.perf-rule-person.is-open {
    border-color: #bfdbfe;
}

.perf-rule-toggle {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 0;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.perf-rule-name {
    font-weight: 600;
}

.perf-rule-summary {
    color: #6b7280;
    font-size: 13px;
}

.perf-rule-body {
    padding: 4px 16px 14px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.perf-rule-subtitle {
    margin: 14px 0 2px;
    font-size: 14px;
}

.perf-rule-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.perf-rule-label {
    flex: 0 0 150px;
    min-width: 0;
    font-size: 14px;
}

.perf-rule-label small {
    display: block;
    color: #9ca3af;
    font-size: 12px;
}

.perf-rule-line select,
.perf-rule-line input {
    padding: 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    font-size: 14px;
}

.perf-rule-line input {
    width: 110px;
}

.perf-cost-line {
    background: white;
    border-bottom: 1px solid #f3f4f6;
    padding: 8px 12px;
}
