/* v1.3.9 · 紧凑型员工绩效数据档案卡。 */

@media screen {
  .performance-id-card {
    grid-template-columns: 82px minmax(0, 1fr) !important;
    grid-template-rows: auto 92px auto auto auto auto !important;
    gap: 0 14px !important;
    padding: 14px !important;
    border: 1px solid #d9e2f2 !important;
    border-top: 0 !important;
    border-radius: 9px !important;
    background: #fff !important;
    box-shadow: 0 8px 24px rgba(38, 58, 108, 0.08) !important;
    overflow: hidden;
  }

  .performance-id-card:hover {
    border-color: #c5d4ee !important;
    box-shadow: 0 12px 28px rgba(38, 58, 108, 0.12) !important;
    transform: translateY(-1px);
  }

  .performance-id-card::before,
  .performance-id-card::after {
    display: none !important;
  }

  .id-card-topline {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 36px !important;
    margin: -14px -14px 12px !important;
    padding: 9px 13px !important;
    border-radius: 9px 9px 0 0 !important;
    background: linear-gradient(108deg, #2f6fe4 0%, #4564d7 100%) !important;
    font-size: 10px !important;
    letter-spacing: 0.045em !important;
  }

  .id-card-topline b {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.035em;
  }

  .performance-id-card .id-photo-area,
  .performance-id-card:has(.id-attendance-summary) .id-photo-area {
    grid-column: 1;
    grid-row: 2;
    width: 74px !important;
    height: 74px !important;
    align-self: center !important;
    justify-self: center;
    aspect-ratio: 1;
    overflow: visible;
  }

  .performance-id-card .id-photo {
    width: 74px !important;
    height: 74px !important;
    aspect-ratio: 1;
  }

  .performance-id-card .id-person-copy,
  .performance-id-card:has(.id-attendance-summary) .id-person-copy {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 236px;
    min-width: 0;
    height: 100%;
    align-self: stretch;
    align-items: center;
    gap: 12px;
    padding: 0 !important;
  }

  .id-person-details > small {
    display: none;
  }

  .id-person-copy h3 {
    margin: 0 !important;
    font-size: 23px !important;
    line-height: 1.12 !important;
  }

  .id-person-name-row {
    margin-bottom: 4px;
  }

  .id-name-grade {
    width: 57px;
    height: 57px;
    flex-basis: 57px;
    border-radius: 12px;
  }

  .id-name-grade .level-emblem {
    width: 51px;
    height: 51px;
    flex-basis: 51px;
  }

  .id-person-copy p {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: #6f7890;
    font-size: 11px !important;
    line-height: 1.4 !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .id-final-score {
    align-self: center;
    gap: 3px;
    padding: 7px;
    border-color: #ded9f4;
    border-left-width: 3px;
    border-radius: 6px;
    background: #f5f3ff;
  }

  .id-final-score > span:first-child {
    font-size: 9px;
  }

  .score-equation {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 13px minmax(0, 1fr) 13px minmax(0, 1fr);
    min-width: 0;
    min-height: 48px;
    align-items: stretch;
    padding: 4px;
    border: 1px solid rgba(90, 56, 220, 0.08);
    border-radius: 5px;
    background: #fff;
    font-variant-numeric: tabular-nums;
  }

  .score-equation-part {
    display: grid;
    min-width: 0;
    align-content: center;
    justify-items: center;
    gap: 3px;
    padding: 2px 3px;
  }

  .score-equation-part small {
    color: #766f90;
    font-size: 8px;
    font-weight: 680;
    line-height: 1.15;
    text-align: center;
    white-space: nowrap;
  }

  .score-equation-part strong {
    color: #343047;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 19px;
    font-weight: 760;
    line-height: 1;
  }

  .score-equation-part.is-total {
    border-radius: 4px;
    background: #eeebff;
  }

  .score-equation-part.is-total small,
  .score-equation-part.is-total strong {
    color: #3d25b5;
  }

  .score-equation > i {
    align-self: center;
    color: #9a92b9;
    font-size: 12px;
    font-style: normal;
    font-weight: 800;
    text-align: center;
  }

  .final-score-value {
    min-height: 38px;
    padding: 3px 8px 4px;
    border-color: rgba(90, 56, 220, 0.08);
  }

  .final-score-value strong {
    font-size: 25px;
  }

  .performance-id-card .id-result-stack,
  .performance-id-card:has(.id-attendance-summary) .id-result-stack {
    grid-column: 1 / -1;
    grid-row: 3;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto;
    min-width: 0;
    margin: 0 0 10px;
    border: 1px solid #dfe6f2;
    border-radius: 7px;
    background: #f8faff;
    box-shadow: none;
    overflow: hidden;
  }

  .id-result-stack > div,
  .id-result-stack .id-self-result,
  .id-result-stack .id-primary-result,
  .id-result-stack .id-secondary-result {
    grid-column: auto;
    grid-row: auto;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) !important;
    min-width: 0;
    min-height: 64px;
    align-content: center;
    align-items: center;
    gap: 7px;
    padding: 8px 9px !important;
    border: 0;
    border-right: 1px solid #e2e8f3;
    background: transparent !important;
  }

  .id-result-stack > div:last-child {
    border-right: 0;
  }

  .id-result-stack > div > span:first-child {
    color: #68748f;
    font-size: 10px !important;
    font-weight: 720;
    line-height: 1.35;
    white-space: normal;
  }

  .id-result-stack .level-badge,
  .id-result-stack .final-grade-badge {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    justify-content: flex-start;
    padding: 3px 6px;
    border: 1px solid rgba(62, 126, 104, 0.1);
    border-radius: 5px;
    box-shadow: none;
  }

  .id-result-stack .level-emblem {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
  }

  .id-result-stack .level-badge b,
  .id-result-stack .final-grade-badge b {
    font-size: 11px;
  }

  .self-assessment-value {
    gap: 1px;
  }

  .self-assessment-value > small {
    overflow: hidden;
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .performance-id-card .id-attendance-summary,
  .performance-id-card:has(.id-attendance-summary) .id-attendance-summary {
    grid-column: 1 / -1;
    grid-row: 4;
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    min-width: 0;
    min-height: 60px;
    margin: 0 0 10px;
    padding: 0;
    border: 1px solid #dce8e4;
    border-left: 3px solid var(--green);
    border-radius: 7px;
    background: #f6faf8;
    overflow: hidden;
  }

  .id-attendance-heading {
    display: grid;
    align-content: center;
    gap: 3px;
    margin: 0;
    padding: 9px 11px;
    border-right: 1px solid #dce8e4;
  }

  .id-attendance-heading span {
    font-size: 10px;
  }

  .id-attendance-heading strong {
    font-size: 9px;
  }

  .id-attendance-summary dl {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    min-width: 0;
    margin: 0;
    padding: 8px 9px;
  }

  .id-attendance-summary dl > div {
    display: grid;
    align-content: center;
    min-width: 0;
    padding: 2px 9px;
    border: 0;
    border-right: 1px solid #e3ebe8;
    background: transparent;
  }

  .id-attendance-summary dl > div:last-child {
    border-right: 0;
  }

  .id-attendance-summary dt {
    font-size: 8px;
  }

  .id-attendance-summary dd {
    margin-top: 3px;
    font-size: 10px;
  }

  .id-attendance-summary > p {
    align-self: center;
    margin: 0;
    padding: 10px 12px;
  }

  .performance-id-card .id-kpi-summary,
  .performance-id-card:has(.id-attendance-summary) .id-kpi-summary {
    grid-column: 1 / -1;
    grid-row: 5;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 10px;
    min-width: 0;
    margin: 0;
    padding: 9px 10px 10px;
    border: 1px solid #e0e5f6;
    border-left: 3px solid var(--blue);
    border-radius: 7px;
    background: #f5f6ff;
    box-shadow: none;
  }

  .performance-id-card:not(:has(.id-attendance-summary)) .id-kpi-summary {
    grid-row: 4;
  }

  .id-kpi-head {
    gap: 10px;
  }

  .id-kpi-head span {
    font-size: 10px;
  }

  .id-kpi-head b {
    font-size: 13px;
  }

  .id-kpi-view-button {
    min-height: 28px;
    padding: 5px 9px;
    font-size: 9px;
  }

  .id-kpi-breakdown {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  .id-kpi-business-item {
    min-height: 28px;
    padding: 5px 7px;
  }

  .id-kpi-business-item dt {
    font-size: 9px;
  }

  .id-kpi-business-item dd {
    font-size: 11px;
  }

  .performance-id-card .id-card-footer,
  .performance-id-card:has(.id-attendance-summary) .id-card-footer {
    grid-column: 1 / -1;
    grid-row: 6;
    align-items: center;
    min-height: 27px;
    margin: 9px 0 -4px;
    padding-top: 8px;
    border-top: 1px solid #e5e9f2;
    font-size: 9px;
  }

  .performance-id-card:not(:has(.id-attendance-summary)) .id-card-footer {
    grid-row: 5;
  }

  @media (max-width: 620px) {
    .performance-id-card {
      grid-template-columns: 74px minmax(0, 1fr) !important;
      grid-template-rows: auto 88px auto auto auto auto !important;
      gap: 0 10px !important;
      padding: 12px !important;
    }

    .id-card-topline {
      margin: -12px -12px 10px !important;
    }

    .performance-id-card .id-photo-area,
    .performance-id-card:has(.id-attendance-summary) .id-photo-area,
    .performance-id-card .id-photo {
      width: 68px !important;
      height: 68px !important;
    }

    .performance-id-card .id-person-copy,
    .performance-id-card:has(.id-attendance-summary) .id-person-copy {
      grid-template-columns: minmax(0, 1fr) 154px;
      gap: 7px;
    }

    .id-person-copy h3 {
      font-size: 19px !important;
    }

    .id-person-name-row {
      gap: 5px;
    }

    .id-name-grade {
      width: 38px;
      height: 38px;
      flex-basis: 38px;
      border-radius: 10px;
    }

    .id-name-grade .level-emblem {
      width: 34px;
      height: 34px;
      flex-basis: 34px;
    }

    .id-person-copy p {
      font-size: 10px !important;
    }

    .id-final-score {
      padding: 5px;
    }

    .score-equation {
      grid-template-columns: minmax(0, 1fr) 9px minmax(0, 1fr) 9px minmax(0, 1fr);
      min-height: 46px;
      padding: 3px;
    }

    .score-equation-part {
      gap: 2px;
      padding-inline: 1px;
    }

    .score-equation-part small {
      max-width: 42px;
      font-size: 7px;
      white-space: normal;
    }

    .score-equation-part strong {
      font-size: 17px;
    }

    .score-equation > i {
      font-size: 10px;
    }

    .final-score-value strong {
      font-size: 23px;
    }

    .performance-id-card .id-result-stack,
    .performance-id-card:has(.id-attendance-summary) .id-result-stack {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .id-result-stack > div,
    .id-result-stack .id-self-result,
    .id-result-stack .id-primary-result,
    .id-result-stack .id-secondary-result {
      grid-template-columns: 58px minmax(0, 1fr) !important;
      min-height: 58px;
      padding: 7px 8px !important;
    }

    .id-result-stack .id-self-result {
      grid-column: 1 / -1;
      border-right: 0;
      border-bottom: 1px solid #e2e8f3;
    }

    .id-result-stack .id-primary-result {
      grid-column: 1;
      grid-row: 2;
    }

    .id-result-stack .id-secondary-result {
      grid-column: 2;
      grid-row: 2;
      border-right: 0;
    }

    .performance-id-card .id-attendance-summary,
    .performance-id-card:has(.id-attendance-summary) .id-attendance-summary {
      grid-template-columns: 1fr;
    }

    .id-attendance-heading {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 8px 10px;
      border-right: 0;
      border-bottom: 1px solid #dce8e4;
    }

    .id-attendance-summary dl {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      padding: 5px 7px;
    }

    .id-attendance-summary dl > div {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      padding: 6px 7px;
      border-bottom: 1px solid #e3ebe8;
    }

    .id-attendance-summary dl > div:nth-child(2n) {
      border-right: 0;
    }

    .id-attendance-summary dl > div:nth-last-child(-n + 2) {
      border-bottom: 0;
    }

    .id-attendance-summary dd {
      margin-top: 0;
    }

    .id-kpi-breakdown {
      grid-template-columns: repeat(5, minmax(0, 1fr));
      gap: 4px;
    }

    .id-kpi-business-item {
      display: grid;
      justify-items: center;
      gap: 3px;
      padding: 5px 2px;
    }

    .id-kpi-view-button {
      width: auto;
    }
  }
}

@media print {
  .performance-id-card {
    break-inside: avoid;
    box-shadow: none !important;
  }
}

/* 员工档案编辑器 v2：桌面双栏、固定标题与操作区、内容区独立滚动。 */

@media screen {
  #employee-dialog {
    width: min(1040px, calc(100vw - 40px));
    max-height: calc(100dvh - 32px);
  }

  #employee-form.compact-modal {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: 100%;
    height: min(760px, calc(100dvh - 32px));
    max-height: calc(100dvh - 32px);
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  #employee-form > .modal-heading {
    z-index: 3;
    min-height: 76px;
    align-items: center;
    padding: 15px 22px;
    border-bottom: 1px solid #dce5f4;
    background: #fff;
  }

  #employee-form > .modal-heading h2 {
    margin-top: 3px;
    font-size: 25px;
  }

  #employee-form .employee-editor-body {
    display: grid;
    grid-template-columns: minmax(340px, 0.9fr) minmax(470px, 1.2fr);
    align-items: start;
    gap: 14px;
    min-height: 0;
    padding: 15px 18px 18px;
    overflow: auto;
    overscroll-behavior: contain;
    background: #f5f8fd;
  }

  #employee-form .employee-editor-column {
    display: grid;
    min-width: 0;
    align-content: start;
    gap: 12px;
  }

  #employee-form .employee-editor-sensitive:not(:has(> section:not([hidden]))) {
    display: none;
  }

  #employee-form .employee-editor-body:not(:has(.employee-editor-sensitive > section:not([hidden]))) {
    grid-template-columns: minmax(0, 620px);
    justify-content: center;
  }

  #employee-form .photo-upload-block {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 14px;
    margin: 0;
    padding: 12px;
    border-color: #dce5f4;
    background: #fff;
  }

  #employee-form .employee-photo-preview {
    width: 82px;
    height: 82px;
    aspect-ratio: 1;
  }

  #employee-form .photo-upload-block p {
    margin: 4px 0 8px;
    line-height: 1.45;
  }

  #employee-form .photo-upload-actions {
    gap: 8px;
  }

  #employee-form .photo-upload-actions .button {
    min-height: 34px;
  }

  #employee-form .employee-editor-basic-fields,
  #employee-form .employee-profile-fields,
  #employee-form .employee-employment-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
  }

  #employee-form.compact-modal .employee-editor-body .field {
    min-width: 0;
    margin: 0;
  }

  #employee-form .employee-editor-body input,
  #employee-form .employee-editor-body select {
    min-height: 40px;
  }

  #employee-form .employee-private-fields,
  #employee-form .employee-salary-fields {
    margin: 0;
    padding: 14px;
  }

  #employee-form .employee-private-heading,
  #employee-form .employee-salary-heading {
    gap: 12px;
  }

  #employee-form .employee-private-heading h3,
  #employee-form .employee-salary-heading h3 {
    font-size: 17px;
  }

  #employee-form .employee-private-heading p,
  #employee-form .employee-salary-heading p {
    margin-top: 4px;
    line-height: 1.45;
  }

  #employee-form .employee-private-inputs,
  #employee-form .employee-salary-inputs {
    gap: 9px;
    margin-top: 11px;
  }

  #employee-form .employee-private-security,
  #employee-form .employee-salary-security {
    margin-top: 8px;
  }

  #employee-form .employee-salary-total {
    min-width: 140px;
    padding: 9px 11px;
  }

  #employee-form .employee-salary-total strong {
    font-size: 17px;
  }

  #employee-form > .modal-actions {
    z-index: 3;
    min-height: 64px;
    align-items: center;
    margin: 0;
    padding: 11px 18px;
    border-top: 1px solid #dce5f4;
    background: #fff;
  }

  #employee-form > .modal-actions .button {
    min-width: 104px;
  }

  @media (max-width: 860px) {
    #employee-dialog {
      width: min(720px, calc(100vw - 24px));
      max-height: calc(100dvh - 20px);
    }

    #employee-form.compact-modal {
      height: calc(100dvh - 20px);
      max-height: calc(100dvh - 20px);
    }

    #employee-form .employee-editor-body {
      grid-template-columns: 1fr;
    }
  }

  @media (max-width: 520px) {
    #employee-dialog {
      width: 100%;
      max-height: 100dvh;
      margin-bottom: 0;
    }

    #employee-form.compact-modal {
      height: 100dvh;
      max-height: 100dvh;
      border-radius: 9px 9px 0 0;
    }

    #employee-form > .modal-heading {
      min-height: 70px;
      padding: 12px 16px;
    }

    #employee-form > .modal-heading h2 {
      font-size: 22px;
    }

    #employee-form .employee-editor-body {
      gap: 10px;
      padding: 12px;
    }

    #employee-form .employee-editor-column {
      gap: 10px;
    }

    #employee-form .employee-editor-basic-fields,
    #employee-form .employee-profile-fields,
    #employee-form .employee-employment-fields {
      grid-template-columns: 1fr;
    }

    #employee-form .employee-profile-fields .employee-profile-wide {
      grid-column: auto;
    }

    #employee-form .photo-upload-block {
      grid-template-columns: 72px minmax(0, 1fr);
      padding: 10px;
    }

    #employee-form .employee-photo-preview {
      width: 72px;
      height: 72px;
    }

    #employee-form > .modal-actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    }

    #employee-form > .modal-actions .button {
      width: 100%;
      min-width: 0;
    }
  }
}

@media print {
  #employee-dialog {
    display: none !important;
  }
}
