body {
  padding-inline: 80px;
}

main {
  #applications {
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding-block: 40px;

    .top {
      display: flex;
      justify-content: space-between;
      align-items: center;

      h1 {
        font-size: 42px;
      }

      button {
        border: none;
        border-radius: 16px;
        padding: 12px 20px;
        font-size: 18px;
        font-weight: 700;
        cursor: pointer;
        color: #ffffff;
        background: linear-gradient(135deg, #b42323, #8f1d1d);
        box-shadow:
          0 8px 24px rgba(143, 29, 29, 0.16),
          inset 0 1px 0 rgba(255, 255, 255, 0.45);
        transition:
          transform 0.2s ease,
          box-shadow 0.2s ease,
          filter 0.2s ease;

        &:hover {
          transform: translateY(-1px);
          filter: brightness(1.03);
          box-shadow:
            0 12px 26px rgba(143, 29, 29, 0.22),
            inset 0 1px 0 rgba(255, 255, 255, 0.55);
        }

        &:active {
          transform: translateY(0);
        }
      }
    }

    .list {
      display: flex;
      flex-direction: column;
      gap: 20px;

      .card {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px;
        border-radius: 25px;
        background: rgba(255, 255, 255, 0.78);
        backdrop-filter: blur(10px);
        transition: 0.3s;

        &:hover {
          background: rgba(255, 255, 255, 0.9);
        }

        .info {
          display: flex;
          flex-direction: column;
          gap: 8px;

          h3 {
            font-size: 24px;
          }

          p {
            font-size: 16px;
            color: rgba(43, 47, 54, 0.6);
          }

          .budget {
            color: #c65a5a;
          }
        }

        .actions {
          .delete {
            border: none;
            border-radius: 12px;
            padding: 8px 14px;
            font-weight: 700;
            color: #ffffff;
            cursor: pointer;
            background: linear-gradient(135deg, #a12b2b, #7f1f1f);
            box-shadow: 0 8px 18px rgba(184, 67, 67, 0.4);
            transition:
              transform 0.2s ease,
              filter 0.2s ease;

            &:hover {
              filter: brightness(1.05);
              transform: translateY(-1px);
            }

            &:active {
              transform: translateY(0);
            }
          }
        }
      }
    }

    .form-card {
      position: relative;
      border-radius: 25px;
      padding: 26px;
      background: rgba(255, 255, 255, 0.82);
      border: 1px solid rgba(143, 29, 29, 0.13);
      backdrop-filter: blur(12px);
      box-shadow:
        0 16px 32px rgba(127, 29, 29, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);

      h2 {
        font-size: 30px;
        margin-bottom: 18px;
      }

      .panel-close-btn {
        position: absolute;
        top: 14px;
        right: 14px;
        width: 36px;
        height: 36px;
        border: none;
        border-radius: 10px;
        background: rgba(127, 31, 31, 0.1);
        color: #7f1f1f;
        font-size: 24px;
        line-height: 1;
        cursor: pointer;
        transition:
          background-color 0.2s ease,
          transform 0.2s ease;

        &:hover {
          background: rgba(127, 31, 31, 0.18);
          transform: translateY(-1px);
        }

        &:active {
          transform: translateY(0);
        }
      }

      .selection-step {
        display: flex;
        flex-direction: column;
        gap: 18px;

        .motivational-quote {
          margin: 0;
          padding: 18px 20px;
          border-left: 4px solid #b42323;
          border-radius: 14px;
          background: rgba(244, 246, 249, 0.9);
          font-size: 20px;
          font-style: italic;
          line-height: 1.45;
          color: rgba(43, 47, 54, 0.92);
        }

        .niches-title {
          margin: 0;
          font-size: 26px;
        }

        .niches-grid {
          display: grid;
          gap: 16px;
        }

        .niche-option {
          border-radius: 18px;
          border: 1px solid rgba(143, 29, 29, 0.14);
          background: rgba(245, 247, 250, 0.9);
          padding: 16px;
          display: flex;
          flex-direction: column;
          gap: 12px;

          h4 {
            margin: 0;
            font-size: 20px;
          }

          p {
            margin: 0;
            color: rgba(43, 47, 54, 0.74);
            line-height: 1.5;
          }

          .classes-grid {
            display: grid;
            gap: 10px;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
          }

          .class-option-btn {
            position: relative;
            overflow: hidden;
            border: 1px solid rgba(143, 29, 29, 0.3);
            background: linear-gradient(135deg, #a12b2b, #7f1f1f);
            border-radius: 14px;
            padding: 12px 44px 12px 14px;
            text-align: left;
            color: #ffffff;
            cursor: pointer;
            font-weight: 600;
            box-shadow:
              0 9px 18px rgba(143, 29, 29, 0.24),
              inset 0 1px 0 rgba(255, 255, 255, 0.28);
            transition:
              transform 0.2s ease,
              border-color 0.2s ease,
              box-shadow 0.2s ease,
              filter 0.2s ease;

            &::after {
              content: ">";
              position: absolute;
              right: 14px;
              top: 50%;
              width: 22px;
              height: 22px;
              border-radius: 999px;
              display: inline-flex;
              align-items: center;
              justify-content: center;
              transform: translateY(-50%);
              font-size: 14px;
              font-weight: 800;
              color: rgba(255, 255, 255, 0.92);
              background: rgba(255, 255, 255, 0.18);
            }

            &:hover {
              transform: translateY(-1px);
              border-color: rgba(143, 29, 29, 0.58);
              background: linear-gradient(135deg, #ac3434, #832626);
              filter: brightness(1.04);
              box-shadow:
                0 12px 26px rgba(143, 29, 29, 0.28),
                inset 0 1px 0 rgba(255, 255, 255, 0.38);
            }

            &:focus-visible {
              outline: none;
              border-color: rgba(143, 29, 29, 0.72);
              box-shadow:
                0 0 0 3px rgba(143, 29, 29, 0.2),
                0 12px 26px rgba(143, 29, 29, 0.26);
            }

            &:active {
              transform: translateY(0);
              filter: brightness(0.98);
            }

            strong {
              display: block;
              margin-bottom: 4px;
              font-size: 16px;
            }

            span {
              display: block;
              font-size: 13px;
              line-height: 1.35;
              color: rgba(223, 223, 223, 0.76);
            }
          }
        }
      }

      #application-form {
        display: flex;
        flex-direction: column;
        gap: 14px;

        .error-message {
          margin-top: 10px;
          color: #d32f2f;
          font-weight: 500;
        }

        .selected-context {
          display: grid;
          gap: 6px;
          padding: 12px 14px;
          border-radius: 12px;
          background: rgba(244, 246, 249, 0.9);
          border: 1px solid rgba(143, 29, 29, 0.13);

          p {
            margin: 0;
            color: rgba(43, 47, 54, 0.86);
          }
        }

        .form-row {
          display: flex;
          flex-direction: column;
          gap: 8px;

          &.has-error {
            label {
              color: #b42323;
            }
          }

          label {
            font-size: 15px;
            font-weight: 600;
            color: rgba(43, 47, 54, 0.86);
          }

          input,
          select,
          textarea {
            width: 100%;
            max-width: 100%;
            min-width: 0;
            border-radius: 14px;
            border: 1px solid rgba(143, 29, 29, 0.15);
            background: rgba(248, 249, 251, 0.96);
            color: #2b2f36;
            font-size: 16px;
            font-family: inherit;
            padding: 12px 14px;
            transition:
              border-color 0.2s ease,
              box-shadow 0.2s ease,
              background-color 0.2s ease;

            &:focus {
              outline: none;
              border-color: rgba(143, 29, 29, 0.55);
              background: rgba(250, 251, 253, 0.98);
              box-shadow: 0 0 0 3px rgba(143, 29, 29, 0.14);
            }
          }

          input,
          select {
            min-height: 48px;
          }

          input[type="date"] {
            color-scheme: light;
            -webkit-appearance: none;
            appearance: none;
            display: block;
            padding-right: 14px;
          }

          select {
            appearance: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            background-image: none !important;
            padding-right: 44px;
            text-indent: 0.01px;
            text-overflow: "";

            &::-ms-expand {
              display: none;
            }
          }

          textarea {
            min-height: 120px;
            resize: vertical;
          }

          .field-error-message {
            color: #b42323;
            font-size: 13px;
            line-height: 1.35;
          }

          input.field-invalid,
          select.field-invalid,
          textarea.field-invalid {
            border-color: rgba(180, 35, 35, 0.72);
            background: rgba(255, 240, 240, 0.95);
            box-shadow: 0 0 0 3px rgba(180, 35, 35, 0.16);
          }

          &.select-row {
            position: relative;

            &::after {
              content: "";
              position: absolute;
              right: 18px;
              top: calc(100% - 24px);
              width: 9px;
              height: 9px;
              border-right: 2px solid #6f1a1a;
              border-bottom: 2px solid #6f1a1a;
              transform: translateY(-50%) rotate(45deg);
              transform-origin: center;
              transition: transform 0.24s ease;
              pointer-events: none;
              opacity: 1;
            }

            &:focus-within::after {
              transform: translateY(-50%) rotate(225deg);
            }
          }
        }

        #submitApplication {
          margin-top: 8px;
          border: none;
          border-radius: 16px;
          padding: 13px 16px;
          font-size: 17px;
          font-weight: 700;
          cursor: pointer;
          color: #ffffff;
          background: linear-gradient(135deg, #b42323, #8f1d1d);
          box-shadow:
            0 10px 24px rgba(143, 29, 29, 0.18),
            inset 0 1px 0 rgba(255, 255, 255, 0.45);
          transition:
            transform 0.2s ease,
            filter 0.2s ease,
            box-shadow 0.2s ease;

          &:hover {
            transform: translateY(-1px);
            filter: brightness(1.03);
            box-shadow:
              0 14px 28px rgba(143, 29, 29, 0.24),
              inset 0 1px 0 rgba(255, 255, 255, 0.55);
          }

          &:active {
            transform: translateY(0);
          }
        }

        .secondary-btn {
          margin-top: 8px;
          border-radius: 16px;
          border: 1px solid rgba(143, 29, 29, 0.18);
          padding: 12px 16px;
          font-size: 16px;
          font-weight: 600;
          cursor: pointer;
          color: rgba(43, 47, 54, 0.92);
          background: rgba(255, 255, 255, 0.78);
          transition:
            transform 0.2s ease,
            background-color 0.2s ease,
            border-color 0.2s ease;

          &:hover {
            transform: translateY(-1px);
            background: rgba(237, 242, 247, 0.72);
            border-color: rgba(143, 29, 29, 0.3);
          }

          &:active {
            transform: translateY(0);
          }
        }
      }
    }
  }
}

@media (max-width: 980px) {
  body {
    padding-inline: 28px;
  }

  main {
    #applications {
      .top {
        h1 {
          font-size: 34px;
        }
      }
    }
  }
}

@media (max-width: 760px) {
  body {
    padding-inline: 16px;
  }

  main {
    #applications {
      .top {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;

        button {
          width: 100%;
        }
      }

      .list {
        .card {
          flex-direction: column;
          align-items: flex-start;
          gap: 16px;
        }
      }

      .form-card {
        padding: 18px;

        h2 {
          font-size: 24px;
        }
      }
    }
  }
}
