.page-new-design {
  &:has(.settings-page) {
    background: var(--new-main-background-color);
    .main { background: var(--new-main-background-color); }
  }

  .settings-page {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 24px 28px 40px;
    background: var(--white);
    border: 1px solid var(--color-border-light);
    border-radius: 12px;
    box-shadow: var(--new-shadow);

    .settings-panel {
      display: grid;
      gap: 12px;
      padding-top: 0;
    }

    .settings-group {
      display: grid;
      gap: 10px;

      h2 {
        margin: 12px 0 2px;
        padding: 0 2px 4px;
        color: var(--color-text-heading);
        font-size: 18px;
        line-height: 1.4;
      }

      &:first-child h2 { margin-top: 0; }
    }

    .settings-group-work { order: 1; }
    .settings-group-matching { order: 2; }
    .settings-group-chat { order: 3; }

    .settings-category {
      margin: 0;
      border: 1px solid var(--color-border-light);
      border-radius: 10px;
      background: var(--white);
      box-shadow: var(--new-shadow);
      overflow: hidden;
      transition: border-color var(--transition-hover-duration) ease, box-shadow var(--transition-hover-duration) ease;

      &[open] {
        border-color: var(--sky-200);
        box-shadow: var(--new-shadow);
      }

      > summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 52px;
        padding: 0 18px;
        list-style: none;
        color: var(--color-text-heading);
        font-size: 15px;
        font-weight: 700;
        cursor: pointer;
        user-select: none;

        &:hover { background: var(--color-hover-background); }

        &::-webkit-details-marker { display: none; }

        &::after {
          content: "";
          width: 8px;
          height: 8px;
          border-right: 2px solid var(--slate-500);
          border-bottom: 2px solid var(--slate-500);
          transform: translateY(-2px) rotate(45deg);
          transition: transform var(--transition-hover-duration) ease;
        }
      }

      &[open] > summary {
        background: var(--sky-50);
        color: var(--sky-800);

        &::after { transform: translateY(2px) rotate(225deg); }
      }
    }

    .settings-category-body {
      padding: 20px 18px 18px;
      border-top: 1px solid var(--color-border-light);
      background: var(--white);

      &.is-collapsed {
        padding-top: 0;
        padding-bottom: 0;
      }
    }

    .match-status-groups-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
    .match-status-group { display: grid; align-content: start; gap: 8px; padding: 12px; border: 1px solid var(--color-border-light); border-radius: 8px; }
    .match-status-group > h3 { margin: 0; color: var(--slate-800); font-size: 16px; font-weight: 700; }
    .match-status-group > .secondary-btn { width: calc(100% - 112px); justify-content: center; border-color: var(--slate-200); background: var(--white); color: var(--slate-600); font-weight: 400; &:hover:not(:disabled) { border-color: var(--slate-300); background: var(--slate-50); color: var(--slate-600); } }
    .match-status-children { display: grid; gap: 8px; }
    .match-status-child-row {
      display: flex;
      gap: 8px;
      > .match-status-move { flex: 0 0 28px; min-height: 32px; padding: 0; border: 1px solid var(--color-border-light); border-radius: 6px; background: var(--white); color: var(--slate-600); cursor: pointer; &:hover:not(:disabled) { background: var(--sky-50); color: var(--sky-800); } &:disabled { opacity: .4; cursor: default; } }
      > .icon-button { flex: 0 0 32px; display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 0; border: 0; border-radius: 6px; background: transparent; cursor: pointer; &:hover { background: var(--red-50); .icon-hover { display: block; } > img:not(.icon-hover) { display: none; } } > img { display: block; width: 14px; height: 14px; } .icon-hover { display: none; } }
      > input { flex: 1 1 auto; min-width: 0; height: var(--control-height); padding: 9px 11px; border: 1px solid var(--color-input-border); border-radius: 7px; background: var(--white); color: var(--slate-600); font-weight: 400; }
    }

    :focus-visible { outline: none; }

    .settings-field {
      gap: 6px;
      margin-bottom: 16px;

      > label { width: auto; color: var(--color-text-label); font-weight: 700; }

      input:not([type="checkbox"]):not([type="radio"]),
      select,
      textarea {
        width: 100%;
        padding: 9px 11px;
        border: 1px solid var(--color-input-border);
        border-radius: 7px;
        background: var(--white);
      }

      input:not([type="checkbox"]):not([type="radio"]),
      select { height: var(--control-height); min-height: var(--control-height); }

      #mail-process-model,
      #match-model,
      #health-assessment-model {
        padding-top: 0;
        padding-bottom: 0;
      }

      #mail-server-retention-days:disabled {
        color: var(--slate-400);
        -webkit-text-fill-color: var(--slate-400);
        opacity: 1;
      }

      textarea {
        min-height: 10rem;
        font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
        resize: vertical;
      }

      &.prompt-settings-field {
        display: block;

        > label {
          display: flex;
          align-items: baseline;
          justify-content: flex-start;
          gap: 12px;
          width: 100%;
        }

        .settings-prompt-counter {
          flex: 0 0 auto;
          color: var(--slate-400);
          font-size: 12px;
          font-weight: 400;
          white-space: nowrap;
        }

        textarea { min-height: 4.5rem; }
      }

      input[type="file"] { padding: 7px 0; }
    }

    .dashboard-contract-target-halves {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 16px;
      width: min(900px, 100%);

      > section {
        min-width: 0;

        > h3 {
          margin: 0 0 8px;
          color: var(--color-text-label);
          font-size: 15px;
        }
      }

      .dashboard-contract-target-table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;

        th, td {
          padding: 9px 12px;
          border-bottom: 1px solid var(--color-border-light);
          text-align: left;
        }

        th { color: var(--color-text-label); font-weight: 700; }
        thead > tr > th:last-child,
        tbody > tr > td:last-child { text-align: right; }
        td > input {
          width: min(140px, 100%);
          min-height: 38px;
          padding: 8px 10px;
          border: 1px solid var(--color-input-border);
          border-radius: 7px;
          background: var(--white);
          text-align: right;
          font-variant-numeric: tabular-nums;

          &:focus-visible { outline: 2px solid var(--sky-500); outline-offset: 1px; }
        }
      }
    }

    .settings-actions {
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      margin-top: 16px;
    }

    .primary-btn, .secondary-btn, .cancel-btn { min-height: 38px; padding: 8px 18px; font-size: 14px; line-height: 20px; }

    .table-actions,
    .mail-template-list-item {
      white-space: nowrap;

      .icon-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        min-height: 32px;
        padding: 0;
        border: 0;
        border-radius: 6px;
        background: transparent;
        transition: background-color var(--transition-hover-duration) ease-out;

        img { display: block; width: 14px; height: 14px; }
        .icon-hover { display: none; }

        &:hover {
          background: var(--sky-50);
          .icon-hover { display: block; }
          > img:not(.icon-hover) { display: none; }
        }

        &.delete-button:hover { background: var(--red-50); }
      }
    }

    .panel-header,
    .toolbar {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 10px;
      margin-bottom: 14px;
    }

    .panel-actions { display: flex; align-items: center; gap: 8px; }

    .data-table {
      width: 100%;
      border-collapse: separate;
      border-spacing: 0;
      overflow: hidden;
      border: 1px solid var(--color-border-light);
      border-radius: 7px;

      th,
      td {
        padding: 10px 12px;
        border-bottom: 1px solid var(--color-border-light);
        text-align: left;
        vertical-align: middle;
      }

      th {
        background: var(--slate-50);
        color: var(--color-text-label);
        font-size: 12px;
        font-weight: 700;
        white-space: nowrap;
      }

      tr:last-child td { border-bottom: 0; }
    }

    .work-log-custom-items-panel,
    .leave-types-panel { overflow-x: auto; }

    .settings-inline-note {
      margin-top: 8px;
      color: var(--color-text-muted);
      font-size: 12px;
      line-height: 1.6;
    }

    .settings-synonyms-grid,
    .local-match-weight-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 16px;
    }

    .settings-synonyms-grid textarea[readonly] { background: var(--slate-50); }

    .settings-custom-items-switch {
      display: flex;
      gap: 4px;
      margin-bottom: 16px;
      border-bottom: 1px solid var(--color-border-light);
    }

    .settings-custom-items-tab {
      min-width: 88px;
      padding: 9px 14px;
      border: 0;
      border-bottom: 2px solid transparent;
      background: transparent;
      color: var(--color-text-muted);

      &.is-active {
        border-bottom-color: var(--sky-500);
        color: var(--sky-700);
        font-weight: 700;
      }
    }

    .settings-custom-items-pane { display: none; }
    .settings-custom-items-pane.is-active { display: block; }

    .unused-tags-list {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
      gap: 8px;
    }

    .unused-tags-item {
      display: flex;
      align-items: center;
      gap: 7px;
      padding: 8px 10px;
      border: 1px solid var(--color-border-light);
      border-radius: 7px;
      background: var(--slate-50);
    }

    .browser-columns-grid {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
      gap: 14px;
      align-items: center;
    }

    .browser-columns-title {
      margin-bottom: 6px;
      color: var(--color-text-label);
      font-size: 13px;
      font-weight: 700;
    }

    .browser-columns-editor select { width: 100%; min-height: 12rem; }

    .browser-columns-actions {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .mail-template-list-item {
      display: flex;
      gap: 8px;
      margin-bottom: 8px;

      > button:first-child { flex: 1; text-align: left; }
    }

  }

  .mail-template-modal {
    .modal-body {
      input,
      textarea { width: 100%; }
    }
  }
}

@media (max-width: 768px) {
  .page-new-design {
    .settings-page {
      width: 100%;
      padding: 18px 14px 28px;
      border-radius: 8px;

      .settings-synonyms-grid,
      .local-match-weight-grid,
      .match-status-groups-editor,
      .browser-columns-grid { grid-template-columns: 1fr; }

      .browser-columns-actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
      }
    }
  }
}
